use of org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta in project pdi-dataservice-server-plugin by pentaho.
the class SqlTransGeneratorTest method testGenTransAllAggsWithAliases.
@Test
public void testGenTransAllAggsWithAliases() throws KettleException {
SQL sql = new SQL("SELECT sum(foo) as c1, avg(bar) as c2, max(baz) as c3 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[] { "c1", "c2", "c3" }));
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 testRowLimit.
@Test
public void testRowLimit() 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, 1);
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 data-access by pentaho.
the class CsvTransformGenerator method createSelectStep.
protected StepMeta createSelectStep(TransMeta transMeta, String stepName) {
SelectValuesMeta meta = new SelectValuesMeta();
// find out which columns need to be deleted
List<String> deleteNameList = new ArrayList<String>();
for (ColumnInfo column : getModelInfo().getColumns()) {
if (column.isIgnore()) {
deleteNameList.add(column.getId());
}
}
if (deleteNameList.size() == 0) {
return null;
}
String[] deleteName = deleteNameList.toArray(new String[deleteNameList.size()]);
meta.setDeleteName(deleteName);
// meta.setID(3);
StepMeta stepMeta = new StepMeta(stepName, stepName, meta);
transMeta.addStep(stepMeta);
return stepMeta;
}
Aggregations