Search in sources :

Example 1 with ValueMetaResolver

use of org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver in project pdi-dataservice-server-plugin by pentaho.

the class SqlTransGeneratorTest method testDataFormatting.

@Test
public void testDataFormatting() throws Exception {
    SQL sql = new SQL("SELECT * FROM table");
    RowMetaInterface rowMeta = new RowMeta();
    rowMeta.addValueMeta(new ValueMetaString("str"));
    rowMeta.addValueMeta(new ValueMetaDate("time"));
    rowMeta.addValueMeta(new ValueMetaInteger("long"));
    sql.parse(new ValueMetaResolver(rowMeta).getRowMeta());
    SqlTransGenerator generator = new SqlTransGenerator(sql, -1);
    TransMeta transMeta = generator.generateTransMeta();
    RowMetaInterface outputFields = transMeta.getStepFields(generator.getResultStepName());
    Calendar calendar = Calendar.getInstance();
    calendar.clear();
    calendar.set(2016, Calendar.FEBRUARY, 12, 13, 20);
    Object[] row = { "value", calendar.getTime(), 42L };
    assertThat(outputFields.getFieldNames(), arrayContaining("str", "time", "long"));
    assertThat(outputFields.getString(row, 0), is("value"));
    assertThat(outputFields.getString(row, 1), is("2016-02-12"));
    assertThat(outputFields.getString(row, 2), is("42"));
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RowMeta(org.pentaho.di.core.row.RowMeta) Calendar(java.util.Calendar) TransMeta(org.pentaho.di.trans.TransMeta) ValueMetaResolver(org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaInteger(org.pentaho.di.core.row.value.ValueMetaInteger) ValueMetaDate(org.pentaho.di.core.row.value.ValueMetaDate) SQL(org.pentaho.di.core.sql.SQL) Test(org.junit.Test)

Example 2 with ValueMetaResolver

use of org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver in project pdi-dataservice-server-plugin by pentaho.

the class MongodbPredicateTest method setup.

@Before
public void setup() {
    for (int i = 0; i < 10; i++) {
        rowMeta.addValueMeta(new ValueMeta("sField" + i, ValueMetaInterface.TYPE_STRING, 50));
        rowMeta.addValueMeta(new ValueMeta("iField" + i, ValueMetaInterface.TYPE_INTEGER, 7));
    }
    resolver = new ValueMetaResolver(rowMeta);
    fieldMappings = new HashMap<String, String>();
}
Also used : ValueMetaResolver(org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver) ValueMeta(org.pentaho.di.core.row.ValueMeta) Before(org.junit.Before)

Aggregations

ValueMetaResolver (org.pentaho.di.trans.dataservice.optimization.ValueMetaResolver)2 Calendar (java.util.Calendar)1 Before (org.junit.Before)1 Test (org.junit.Test)1 RowMeta (org.pentaho.di.core.row.RowMeta)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMeta (org.pentaho.di.core.row.ValueMeta)1 ValueMetaDate (org.pentaho.di.core.row.value.ValueMetaDate)1 ValueMetaInteger (org.pentaho.di.core.row.value.ValueMetaInteger)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 SQL (org.pentaho.di.core.sql.SQL)1 TransMeta (org.pentaho.di.trans.TransMeta)1