use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-cassandra-plugin by pentaho.
the class DriverCQLRowHandlerTest method testBatchInsertIgnoreColumns.
@Test
public void testBatchInsertIgnoreColumns() throws Exception {
DriverKeyspace keyspace = mock(DriverKeyspace.class);
when(keyspace.getName()).thenReturn("ks");
Session session = mock(Session.class);
TableMetaData familyMeta = mock(TableMetaData.class);
when(familyMeta.getTableName()).thenReturn("tab");
ArrayList<Object[]> batch = new ArrayList<>();
batch.add(new Object[] { 1, 1L, 2L, 3L, 4L });
batch.add(new Object[] { 2, 5L, 6L, 7L, 8L });
RowMeta rowMeta = new RowMeta();
rowMeta.addValueMeta(new ValueMetaInteger("nope"));
rowMeta.addValueMeta(new ValueMetaInteger("there1"));
rowMeta.addValueMeta(new ValueMetaInteger("not there"));
rowMeta.addValueMeta(new ValueMetaInteger("there2"));
rowMeta.addValueMeta(new ValueMetaInteger("also not there"));
when(familyMeta.columnExistsInSchema(anyString())).then(args -> {
return ((String) args.getArguments()[0]).startsWith("there");
});
DriverCQLRowHandler rowHandler = new DriverCQLRowHandler(keyspace, session, true);
rowHandler.setUnloggedBatch(false);
rowHandler.batchInsert(rowMeta, batch, familyMeta, "TWO", false, null);
verify(session, times(1)).execute(argThat(new ArgumentMatcher<Statement>() {
@Override
public boolean matches(Object argument) {
Statement stmt = (Statement) argument;
return stmt.toString().equals("BEGIN BATCH INSERT INTO ks.tab (there1,there2) " + "VALUES (1,3);INSERT INTO ks.tab (there1,there2) VALUES (5,7);APPLY BATCH;") && stmt.getConsistencyLevel().equals(ConsistencyLevel.TWO);
}
}));
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-cassandra-plugin by pentaho.
the class DriverCQLRowHandlerTest method testQueryRowsTimestamp.
@Test
public void testQueryRowsTimestamp() {
Row row = mock(Row.class);
when(row.getLong(0)).thenReturn(1L);
when(row.getTimestamp(1)).thenReturn(new Date(1520538054000L));
when(row.getDate(2)).thenReturn(LocalDate.fromYearMonthDay(2018, 03, 12));
assertEquals(1L, DriverCQLRowHandler.readValue(new ValueMetaInteger("row"), row, 0));
assertEquals(new Date(1520538054000L), DriverCQLRowHandler.readValue(new ValueMetaTimestamp("timestamp"), row, 1));
assertEquals(LocalDate.fromYearMonthDay(2018, 03, 12), DriverCQLRowHandler.readValue(new ValueMetaDate("datestamp"), row, 2));
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method insertStepDatabase.
public synchronized void insertStepDatabase(ObjectId id_transformation, ObjectId id_step, ObjectId id_database) throws KettleException {
// First check if the relationship is already there.
// There is no need to store it twice!
RowMetaAndData check = getStepDatabase(id_step);
if (check.getInteger(0) == null) {
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_TRANSFORMATION), id_transformation);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_STEP), id_step);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_STEP_DATABASE_ID_DATABASE), id_database);
connectionDelegate.insertTableRow(KettleDatabaseRepository.TABLE_R_STEP_DATABASE, table);
}
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method insertClusterSlave.
public synchronized ObjectId insertClusterSlave(ClusterSchema clusterSchema, SlaveServer slaveServer) throws KettleException {
ObjectId id = connectionDelegate.getNextClusterSlaveID();
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_CLUSTER_SLAVE), id);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_CLUSTER), clusterSchema.getObjectId());
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_CLUSTER_SLAVE_ID_SLAVE), slaveServer.getObjectId());
connectionDelegate.insertTableRow(KettleDatabaseRepository.TABLE_R_CLUSTER_SLAVE, table);
return id;
}
use of org.pentaho.di.core.row.value.ValueMetaInteger in project pentaho-kettle by pentaho.
the class KettleDatabaseRepository method insertJobEntryDatabase.
public synchronized void insertJobEntryDatabase(ObjectId id_job, ObjectId id_jobentry, ObjectId id_database) throws KettleException {
// First check if the relationship is already there.
// There is no need to store it twice!
RowMetaAndData check = getJobEntryDatabase(id_jobentry);
if (check.getInteger(0) == null) {
RowMetaAndData table = new RowMetaAndData();
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOB), id_job);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_JOBENTRY), id_jobentry);
table.addValue(new ValueMetaInteger(KettleDatabaseRepository.FIELD_JOBENTRY_DATABASE_ID_DATABASE), id_database);
connectionDelegate.insertTableRow(KettleDatabaseRepository.TABLE_R_JOBENTRY_DATABASE, table);
}
}
Aggregations