use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testFilterStep.
@Test
public void testFilterStep() throws KettleException {
SQL sql = new SQL("SELECT * FROM table WHERE foo > 1");
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 testGenTransAllAggsNoAliases.
@Test
public void testGenTransAllAggsNoAliases() throws KettleException {
SQL sql = new SQL("SELECT sum(foo), avg(bar), max(baz) FROM table");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("foo"));
rowMeta.addValueMeta(new ValueMetaInteger("bar"));
rowMeta.addValueMeta(new ValueMetaString("baz"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta(generator.generateTransMeta());
assertThat(selectValuesMeta.getSelectName(), equalTo(new String[] { "foo", "bar", "baz" }));
assertThat(selectValuesMeta.getSelectRename(), equalTo(new String[] { null, null, null }));
}
use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testTypeHandlingWithAvg.
@Test
public void testTypeHandlingWithAvg() throws KettleException {
SQL sql = new SQL("SELECT avg( intVal ), avg( numericVal ), avg( bigNumber) FROM table");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("intVal"));
rowMeta.addValueMeta(new ValueMetaNumber("numericVal"));
rowMeta.addValueMeta(new ValueMetaBigNumber("bigNumber"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta meta = (SelectValuesMeta) getStepByName(generator.generateTransMeta(), "Set Conversion");
assertThat(meta.getMeta().length, is(3));
// Integer should be converted to TYPE_NUMBER
assertThat(meta.getMeta()[0].getType(), is(TYPE_NUMBER));
// Other types should be left alone ( SelectMetadataChange.getType remains TYPE_NONE )
assertThat(meta.getMeta()[1].getType(), is(TYPE_NONE));
assertThat(meta.getMeta()[2].getType(), is(TYPE_NONE));
}
use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testGenerateConstStep.
@Test
public void testGenerateConstStep() throws KettleException {
SQL sql = new SQL("SELECT 'FOO' as 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[] { "foo" }));
}
use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testGenTransUsingSqlWithGroupByOrderByNoAlias.
@Test
public void testGenTransUsingSqlWithGroupByOrderByNoAlias() throws KettleException {
SQL sql = new SQL("SELECT foo, bar, baz FROM table GROUP BY foo, bar, baz ORDER BY foo");
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("foo"));
rowMeta.addValueMeta(new ValueMetaInteger("bar"));
rowMeta.addValueMeta(new ValueMetaString("baz"));
sql.parse(rowMeta);
SqlTransGenerator generator = new SqlTransGenerator(sql, 0);
SelectValuesMeta selectValuesMeta = getSelectStepValuesMeta(generator.generateTransMeta());
assertThat(selectValuesMeta.getSelectName(), equalTo(new String[] { "foo", "bar", "baz" }));
assertThat(selectValuesMeta.getSelectRename(), equalTo(new String[] { null, null, null }));
}
Aggregations