use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testGenerateIifStep.
@Test
public void testGenerateIifStep() throws KettleException {
SQL sql = new SQL("SELECT IIF(10 > 1, 'TRUE', 'FALSE') FROM table");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("foo"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta(generator.generateTransMeta());
assertThat(selectValuesMeta.getSelectName(), equalTo(new String[] { "IIF(10 > 1, 'TRUE', 'FALSE')" }));
assertThat(selectValuesMeta.getSelectRename(), equalTo(new String[] { null }));
}
use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testGenTransSelectStar.
@Test
public void testGenTransSelectStar() throws KettleException {
SQL sql = new SQL("SELECT * FROM table");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("foo"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta(generator.generateTransMeta());
assertThat(selectValuesMeta.getSelectName(), equalTo(new String[] { "foo" }));
assertThat(selectValuesMeta.getSelectRename(), equalTo(new String[] { null }));
}
use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testUniqueStep.
@Test
public void testUniqueStep() throws KettleException {
SQL sql = new SQL("SELECT DISTINCT foo FROM table");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("foo"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta(generator.generateTransMeta());
assertThat(selectValuesMeta.getSelectName(), equalTo(new String[] { "foo" }));
assertThat(selectValuesMeta.getSelectRename(), equalTo(new String[] { null }));
}
use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testLimitClause.
@Test
public void testLimitClause() throws KettleException {
SQL sql = new SQL("SELECT * FROM table LIMIT 1");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("foo"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta(generator.generateTransMeta());
assertThat(selectValuesMeta.getSelectName(), equalTo(new String[] { "foo" }));
assertThat(selectValuesMeta.getSelectRename(), equalTo(new String[] { null }));
assertThat(sql.getLimitClause(), notNullValue());
}
use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testGenTransUsingSqlWithAggAndAliases.
@Test
public void testGenTransUsingSqlWithAggAndAliases() throws KettleException {
SQL sql = new SQL("SELECT \"FACT\".\"mth\" AS \"COL0\",AVG(\"FACT\".\"bmi\") AS \"COL1\"," + "\"FACT\".\"gender\" AS \"COL2\" FROM \"FACT\" GROUP BY \"FACT\".\"mth\",\"FACT\".\"gender\"");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("mth"));
rowMeta.addValueMeta(new ValueMetaInteger("bmi"));
rowMeta.addValueMeta(new ValueMetaString("gender"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta(generator.generateTransMeta());
assertThat(selectValuesMeta.getSelectName(), equalTo(new String[] { "mth", "COL1", "gender" }));
assertThat(selectValuesMeta.getSelectRename(), equalTo(new String[] { "COL0", null, "COL2" }));
}
Aggregations