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

    String sqlString =
        "SELECT DISTINCT\n          BT_SERVICE_SERVICE.Category AS COL0\n         ,BT_SERVICE_SERVICE.Country AS COL1\n"
            + "         ,BT_SERVICE_SERVICE.products_sold AS COL2\n         ,BT_SERVICE_SERVICE.sales_amount AS COL3\n"
            + "FROM \n          Service BT_SERVICE_SERVICE\n"
            + "ORDER BY\n          COL0";

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

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

    assertTrue(sql.getSelectFields().isDistinct());
    List<SqlField> selectFields = sql.getSelectFields().getFields();
    assertEquals(4, selectFields.size());
    assertEquals("COL0", selectFields.get(0).getAlias());
    assertEquals("COL1", selectFields.get(1).getAlias());
    assertEquals("COL2", selectFields.get(2).getAlias());
    assertEquals("COL3", selectFields.get(3).getAlias());

    List<SqlField> orderFields = sql.getOrderFields().getFields();
    assertEquals(1, orderFields.size());
  }
/**
   * Query generated by interactive reporting.
   *
   * @throws Exception
   */
Query generated by interactive reporting.
@throws Exception
Query generated by interactive reporting . @throws Exception
@Test
  public void testSql06() throws Exception {
    IRowMeta rowMeta = generateServiceRowMeta();
    String sqlString =
        "SELECT DISTINCT\n          BT_SERVICE_SERVICE.Category AS COL0\n         ,BT_SERVICE_SERVICE.Country AS COL1\n"
            + "         ,BT_SERVICE_SERVICE.products_sold AS COL2\n         ,BT_SERVICE_SERVICE.sales_amount AS COL3\n"
            + "FROM \n          Service BT_SERVICE_SERVICE\n"
            + "ORDER BY\n          COL0";
    Sql sql = new Sql(ThinUtil.stripNewlines(sqlString));
    assertEquals("Service", sql.getServiceName());
    sql.parse(rowMeta);
    assertTrue(sql.getSelectFields().isDistinct());
    List<SqlField> selectFields = sql.getSelectFields().getFields();
    assertEquals(4, selectFields.size());
    assertEquals("COL0", selectFields.get(0).getAlias());
    assertEquals("COL1", selectFields.get(1).getAlias());
    assertEquals("COL2", selectFields.get(2).getAlias());
    assertEquals("COL3", selectFields.get(3).getAlias());
    List<SqlField> orderFields = sql.getOrderFields().getFields();
    assertEquals(1, orderFields.size());
  }
@ Test public void testSql06 ( ) throws Exception { IRowMeta rowMeta = generateServiceRowMeta ( ) ; String sqlString = "SELECT DISTINCT\n          BT_SERVICE_SERVICE.Category AS COL0\n         ,BT_SERVICE_SERVICE.Country AS COL1\n" + "         ,BT_SERVICE_SERVICE.products_sold AS COL2\n         ,BT_SERVICE_SERVICE.sales_amount AS COL3\n" + "FROM \n          Service BT_SERVICE_SERVICE\n" + "ORDER BY\n          COL0" ; Sql sql = new Sql ( ThinUtil . stripNewlines ( sqlString ) ) ; assertEquals ( "Service" , sql . getServiceName ( ) ) ; sql . parse ( rowMeta ) ; assertTrue ( sql . getSelectFields ( ) . isDistinct ( ) ) ; List < SqlField > selectFields = sql . getSelectFields ( ) . getFields ( ) ; assertEquals ( 4 , selectFields . size ( ) ) ; assertEquals ( "COL0" , selectFields . get ( 0 ) . getAlias ( ) ) ; assertEquals ( "COL1" , selectFields . get ( 1 ) . getAlias ( ) ) ; assertEquals ( "COL2" , selectFields . get ( 2 ) . getAlias ( ) ) ; assertEquals ( "COL3" , selectFields . get ( 3 ) . getAlias ( ) ) ; List < SqlField > orderFields = sql . getOrderFields ( ) . getFields ( ) ; assertEquals ( 1 , orderFields . size ( ) ) ; }
Query generated by interactive reporting.
Query generated by interactive reporting .