core/src/test/java/org/apache/hop/core/sql/SqlTest.java
@Test
  public void testSql08() throws Exception {
    IRowMeta rowMeta = generateZipsRowMeta();

    String sqlString =
        "SELECT            BT_MONGODB_MONGODB.state AS COL0          ,SUM(BT_MONGODB_MONGODB.rows) AS COL1 FROM        "
            + "    MongoDB BT_MONGODB_MONGODB GROUP BY            BT_MONGODB_MONGODB.state ORDER BY            COL1 DESC";

    Sql sql = new Sql(ThinUtil.stripNewlines(sqlString));

    assertEquals("MongoDB", sql.getServiceName());
    sql.parse(rowMeta);

    assertFalse(sql.getSelectFields().isDistinct());
    List<SqlField> selectFields = sql.getSelectFields().getFields();
    assertEquals(2, selectFields.size());
    assertEquals("state", selectFields.get(0).getField());
    assertEquals("COL0", selectFields.get(0).getAlias());
    assertEquals("rows", selectFields.get(1).getField());
    assertEquals("COL1", selectFields.get(1).getAlias());

    List<SqlField> orderFields = sql.getOrderFields().getFields();
    assertEquals(1, orderFields.size());
  }
/**
   * Query generated by PIR
   *
   * @throws Exception
   */
Query generated by PIR
@throws Exception
Query generated by PIR @throws Exception
@Test
  public void testSql08() throws Exception {
    IRowMeta rowMeta = generateZipsRowMeta();
    String sqlString =
        "SELECT            BT_MONGODB_MONGODB.state AS COL0          ,SUM(BT_MONGODB_MONGODB.rows) AS COL1 FROM        "
            + "    MongoDB BT_MONGODB_MONGODB GROUP BY            BT_MONGODB_MONGODB.state ORDER BY            COL1 DESC";
    Sql sql = new Sql(ThinUtil.stripNewlines(sqlString));
    assertEquals("MongoDB", sql.getServiceName());
    sql.parse(rowMeta);
    assertFalse(sql.getSelectFields().isDistinct());
    List<SqlField> selectFields = sql.getSelectFields().getFields();
    assertEquals(2, selectFields.size());
    assertEquals("state", selectFields.get(0).getField());
    assertEquals("COL0", selectFields.get(0).getAlias());
    assertEquals("rows", selectFields.get(1).getField());
    assertEquals("COL1", selectFields.get(1).getAlias());
    List<SqlField> orderFields = sql.getOrderFields().getFields();
    assertEquals(1, orderFields.size());
  }
@ Test public void testSql08 ( ) throws Exception { IRowMeta rowMeta = generateZipsRowMeta ( ) ; String sqlString = "SELECT            BT_MONGODB_MONGODB.state AS COL0          ,SUM(BT_MONGODB_MONGODB.rows) AS COL1 FROM        " + "    MongoDB BT_MONGODB_MONGODB GROUP BY            BT_MONGODB_MONGODB.state ORDER BY            COL1 DESC" ; Sql sql = new Sql ( ThinUtil . stripNewlines ( sqlString ) ) ; assertEquals ( "MongoDB" , sql . getServiceName ( ) ) ; sql . parse ( rowMeta ) ; assertFalse ( sql . getSelectFields ( ) . isDistinct ( ) ) ; List < SqlField > selectFields = sql . getSelectFields ( ) . getFields ( ) ; assertEquals ( 2 , selectFields . size ( ) ) ; assertEquals ( "state" , selectFields . get ( 0 ) . getField ( ) ) ; assertEquals ( "COL0" , selectFields . get ( 0 ) . getAlias ( ) ) ; assertEquals ( "rows" , selectFields . get ( 1 ) . getField ( ) ) ; assertEquals ( "COL1" , selectFields . get ( 1 ) . getAlias ( ) ) ; List < SqlField > orderFields = sql . getOrderFields ( ) . getFields ( ) ; assertEquals ( 1 , orderFields . size ( ) ) ; }
Query generated by PIR
 @throws Exception
Query generated by PIR @throws Exception