Search in sources :

Example 16 with SelectValuesMeta

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 }));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) SelectValuesMeta(org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 17 with SelectValuesMeta

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 }));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) SelectValuesMeta(org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta) RowMeta(org.pentaho.di.core.row.RowMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 18 with SelectValuesMeta

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;
}
Also used : SelectValuesMeta(org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta) ArrayList(java.util.ArrayList) ColumnInfo(org.pentaho.platform.dataaccess.datasource.wizard.models.ColumnInfo) StepMeta(org.pentaho.di.trans.step.StepMeta)

Aggregations

SelectValuesMeta (org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta)18 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)15 Test (org.junit.Test)13 SQL (org.pentaho.di.core.sql.SQL)13 RowMeta (org.pentaho.di.core.row.RowMeta)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)9 StepMeta (org.pentaho.di.trans.step.StepMeta)5 KettleException (org.pentaho.di.core.exception.KettleException)3 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)3 SQLField (org.pentaho.di.core.sql.SQLField)2 TransHopMeta (org.pentaho.di.trans.TransHopMeta)2 TransMeta (org.pentaho.di.trans.TransMeta)2 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)2 SelectMetadataChange (org.pentaho.di.trans.steps.selectvalues.SelectMetadataChange)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Condition (org.pentaho.di.core.Condition)1