use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.
the class JDBCInputPTransformRuntime method initialize.
@Override
public ValidationResult initialize(RuntimeContainer container, JDBCInputProperties properties) {
this.properties = properties;
// In Beam, JdbcIO always has a repartition event, so we are obligated to fetch the schema before any processing
// occurs in the nodes.
Schema schema = properties.getDatasetProperties().main.schema.getValue();
if (schema == null || AvroUtils.isSchemaEmpty(schema) || AvroUtils.isIncludeAllFields(schema)) {
JDBCDatasetRuntime schemaFetcher = new JDBCDatasetRuntime();
schemaFetcher.initialize(container, properties.getDatasetProperties());
schema = schemaFetcher.getSchema();
}
this.defaultOutputCoder = AvroCoder.of(schema);
return ValidationResult.OK;
}
use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.
the class JDBCDatasetTestIT method testGetSchemaFromTable.
@Test
public void testGetSchemaFromTable() throws IOException {
JDBCDatasetProperties dataset = createDatasetProperties(false);
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
JDBCSourceOrSink jss = new JDBCSourceOrSink();
jss.initialize(null, dataset);
Schema schema = jss.getEndpointSchema(null, tablename);
Assert.assertNotNull(schema);
DBTestUtils.testMetadata(schema.getFields(), true);
jss.getEndpointSchema(null, tablename_all_type);
// TODO assert the result
}
use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.
the class JDBCDatasetTestIT method updateSchema.
protected void updateSchema(JDBCDatasetProperties dataset) {
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
dataset.main.schema.setValue(runtime.getSchema());
}
use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.
the class JDBCDatasetTestIT method getSampleAction.
private void getSampleAction(JDBCDatasetProperties dataset) {
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
final IndexedRecord[] record = new IndexedRecord[1];
Consumer<IndexedRecord> storeTheRecords = new Consumer<IndexedRecord>() {
@Override
public void accept(IndexedRecord data) {
record[0] = data;
}
};
runtime.getSample(1, storeTheRecords);
Assert.assertEquals("1", record[0].get(0));
Assert.assertEquals("wangwei", record[0].get(1));
}
use of org.talend.components.jdbc.runtime.dataprep.JDBCDatasetRuntime in project components by Talend.
the class JDBCDatasetOracleTestIT method testGetSchema.
@Ignore
@Test
public void testGetSchema() {
JDBCDatasetProperties dataset = createDatasetProperties();
JDBCDatasetRuntime runtime = new JDBCDatasetRuntime();
runtime.initialize(null, dataset);
Schema schema = runtime.getSchema();
Assert.assertNotNull(schema);
Assert.assertEquals(2, schema.getFields().size());
}
Aggregations