use of org.talend.components.snowflake.runtime.SnowflakeSink in project components by Talend.
the class SnowflakeRuntimeIT method makeWriter.
// Returns the rows written (having been re-read so they have their Ids)
protected Writer<Result> makeWriter(SnowflakeConnectionTableProperties props) throws Exception {
SnowflakeSink SnowflakeSink = new SnowflakeSink();
SnowflakeSink.initialize(container, props);
SnowflakeSink.validate(container);
SnowflakeWriteOperation writeOperation = SnowflakeSink.createWriteOperation();
return writeOperation.createWriter(container);
}
use of org.talend.components.snowflake.runtime.SnowflakeSink in project components by Talend.
the class SnowflakeWritersTestIT method testOutputFeedback.
@Test
public void testOutputFeedback() throws Throwable {
TSnowflakeOutputProperties props = (TSnowflakeOutputProperties) getComponentService().getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME);
setupProps(props.getConnectionProperties());
setupTableWithStaticValues(props);
props.outputAction.setStoredValue(TSnowflakeOutputProperties.OutputAction.INSERT);
DefaultComponentRuntimeContainerImpl container = new DefaultComponentRuntimeContainerImpl();
// Initialize the Sink, WriteOperation and Writer
SnowflakeSink sfSink = new SnowflakeSink();
sfSink.initialize(container, props);
sfSink.validate(container);
SnowflakeWriteOperation sfWriteOp = sfSink.createWriteOperation();
sfWriteOp.initialize(container);
SnowflakeWriter sfWriter = sfSink.createWriteOperation().createWriter(container);
sfWriter.open("uid1");
List<IndexedRecord> rows = makeRows(2);
IndexedRecord r = rows.get(0);
r.put(0, "badId");
r.put(2, "badBoolean");
r.put(4, "badDate");
r.put(5, "badTime");
r.put(6, "badTimestamp");
sfWriter.write(r);
sfWriter.write(rows.get(1));
Result wr1 = sfWriter.close();
// The rejected writes would come in here
Iterable<IndexedRecord> rejected = sfWriter.getRejectedWrites();
Iterator<IndexedRecord> it = rejected.iterator();
IndexedRecord rej;
rej = it.next();
// row
assertEquals("1", rej.get(1));
// character
assertEquals("1", rej.get(3));
assertThat((String) rej.get(4), containsString("Numeric value 'badId'"));
// byte offset
assertEquals("0", rej.get(5));
// line
assertEquals("1", rej.get(6));
// code
assertEquals("100038", rej.get(8));
rej = it.next();
// row
assertEquals("1", rej.get(1));
// character
assertEquals("13", rej.get(3));
assertThat((String) rej.get(4), containsString("Boolean value 'badBoolean'"));
// byte offset
assertEquals("12", rej.get(5));
// line
assertEquals("1", rej.get(6));
// code
assertEquals("100037", rej.get(8));
rej = it.next();
// row
assertEquals("1", rej.get(1));
// character
assertEquals("32", rej.get(3));
assertThat((String) rej.get(4), containsString("Date 'badDate'"));
// byte offset
assertEquals("31", rej.get(5));
// line
assertEquals("1", rej.get(6));
// code
assertEquals("100040", rej.get(8));
rej = it.next();
// row
assertEquals("1", rej.get(1));
// character
assertEquals("40", rej.get(3));
assertThat((String) rej.get(4), containsString("Time 'badTime'"));
// byte offset
assertEquals("39", rej.get(5));
// line
assertEquals("1", rej.get(6));
// code
assertEquals("100108", rej.get(8));
rej = it.next();
// row
assertEquals("1", rej.get(1));
// character
assertEquals("48", rej.get(3));
assertThat((String) rej.get(4), containsString("Timestamp 'badTimestamp'"));
// byte offset
assertEquals("47", rej.get(5));
// line
assertEquals("1", rej.get(6));
// code
assertEquals("100035", rej.get(8));
assertFalse(it.hasNext());
assertEquals(1, wr1.getSuccessCount());
assertEquals(1, wr1.getRejectCount());
assertEquals(2, wr1.getTotalCount());
sfWriteOp.finalize(Arrays.asList(wr1), container);
}
use of org.talend.components.snowflake.runtime.SnowflakeSink in project components by Talend.
the class SnowflakeWritersTestIT method createSnowflakeOutputWriter.
public Writer<Result> createSnowflakeOutputWriter(TSnowflakeOutputProperties props) {
SnowflakeSink SnowflakeSink = new SnowflakeSink();
SnowflakeSink.initialize(container, props);
SnowflakeWriteOperation writeOperation = SnowflakeSink.createWriteOperation();
Writer<Result> writer = writeOperation.createWriter(container);
return writer;
}
Aggregations