Search in sources :

Example 11 with SelectValuesMeta

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 }));
}
Also used : 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 12 with SelectValuesMeta

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 }));
}
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 13 with SelectValuesMeta

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 }));
}
Also used : 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 14 with SelectValuesMeta

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());
}
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 15 with SelectValuesMeta

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" }));
}
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)

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