use of org.pentaho.di.core.row.value.ValueMetaInteger 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.core.row.value.ValueMetaInteger 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 }));
}
use of org.pentaho.di.core.row.value.ValueMetaInteger 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 }));
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pdi-dataservice-server-plugin by pentaho.
the class CachedServiceTest method setUp.
@Before
public void setUp() throws Exception {
rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaString("ID"));
rowMeta.addValueMeta(new ValueMetaInteger("A"));
rowMeta.addValueMeta(new ValueMetaInteger("B"));
testData = Lists.newArrayListWithExpectedSize(100);
for (long i = 0; i < 100; i++) {
testData.add(new RowMetaAndData(rowMeta, String.valueOf(i), i % 13, i % 17));
}
when(serviceTrans.findRunThread(SERVICE_STEP)).thenReturn(serviceStep);
when(serviceStep.getTrans()).thenReturn(serviceTrans);
when(sqlTransGenerator.getInjectorStepName()).thenReturn(INJECTOR_STEP);
transMeta = serviceTrans.getTransMeta();
when(transMeta.getCacheVersion()).thenReturn(1);
dataServiceMeta = new DataServiceMeta(transMeta);
dataServiceMeta.setName(SERVICE_NAME);
dataServiceMeta.setStepname(SERVICE_STEP);
when(transMeta.getStepFields(SERVICE_STEP)).thenReturn(rowMeta);
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-cassandra-plugin by pentaho.
the class DriverCQLRowHandlerTest method testExpandCollection.
@Test
public void testExpandCollection() throws Exception {
List<Object[]> rowList = new ArrayList<Object[]>();
ArrayList<Long> numList = new ArrayList<Long>();
numList.add(1L);
numList.add(2L);
numList.add(3L);
rowList.add(new Object[] { 1L, numList });
rowList.add(new Object[] { 2L, new ArrayList<Long>() });
Iterator<Object[]> it = rowList.iterator();
DriverKeyspace keyspace = mock(DriverKeyspace.class);
Session session = mock(Session.class);
ResultSet rs = mock(ResultSet.class);
when(session.execute(anyString())).thenReturn(rs);
when(rs.isExhausted()).then(invoc -> {
return !it.hasNext();
});
when(rs.one()).then(invocation -> {
Object[] rowArr = it.next();
Row row = mock(Row.class);
when(row.getObject(anyInt())).then(invoc -> {
return rowArr[(int) invoc.getArguments()[0]];
});
when(row.getLong(0)).thenReturn((long) rowArr[0]);
return row;
});
mockColumnDefinitions(rs, DataType.bigint(), DataType.list(DataType.bigint()));
DriverCQLRowHandler rowHandler = new DriverCQLRowHandler(keyspace, session, true);
RowMetaInterface rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("id"));
rowMeta.addValueMeta(new ValueMetaNumber("nums"));
rowHandler.newRowQuery(mock(StepInterface.class), "tab", "select * from tab", null, null, mock(LogChannelInterface.class));
List<Object[]> resultRows = getNextOutputRows(rowHandler, rowMeta);
assertEquals(4, resultRows.size());
assertEquals(1L, resultRows.get(0)[1]);
assertEquals(2L, resultRows.get(3)[0]);
assertNull(resultRows.get(3)[1]);
}
Aggregations