Source:
public void testCreateTableDynamicSchema() throws IOException, SQLException { TSnowflakeOutputProperties outputProps = (TSnowflakeOutputProperties) getComponentService() .getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME); setupProps(outputProps.connection); outputProps.tableAction.setValue(TableAction.TableActionEnum.CREATE); String tableName = "TDI42854_" + testNumber; outputProps.table.tableName.setValue(tableName); Schema designSchema = SchemaBuilder.builder().record("design") .prop(SchemaConstants.INCLUDE_ALL_FIELDS, "true") .fields() .requiredString("staticColumn") .endRecord(); outputProps.table.main.schema.setValue(designSchema); SnowflakeSink sink = new SnowflakeSink(); RuntimeContainer container = new DefaultComponentRuntimeContainerImpl(); sink.initialize(container, outputProps); sink.validate(container); SnowflakeWriteOperation writeOperation = sink.createWriteOperation(); SnowflakeWriter writer = writeOperation.createWriter(container); Schema runtimeSchema = SchemaBuilder.builder().record("runtime").fields() .requiredString("C1") .requiredString("C2") .requiredString("C3") .requiredString("STATICCOLUMN") .endRecord(); IndexedRecord record = new GenericData.Record(runtimeSchema); record.put(0, "c1_value"); record.put(1, "c2_value"); record.put(2, "c3_value"); record.put(3, "staticColumn_value"); Connection connection = null; try { writer.open("random uId"); writer.write(record); writer.close(); connection = sink.createConnection(container); DatabaseMetaData metaData = connection.getMetaData(); ResultSet rs = metaData.getColumns(DB, testSchema, tableName, null); rs.next(); Assert.assertEquals("C1", rs.getString("COLUMN_NAME")); rs.next(); Assert.assertEquals("C2", rs.getString("COLUMN_NAME")); rs.next(); Assert.assertEquals("C3", rs.getString("COLUMN_NAME")); rs.next(); Assert.assertEquals("STATICCOLUMN", rs.getString("COLUMN_NAME")); Assert.assertFalse(rs.next()); rs.close(); } finally { execute(connection, "drop table if exists " + tableName); sink.closeConnection(container, connection); } }

Target:
public void testCreateTableDynamicSchema() throws IOException, SQLException { TSnowflakeOutputProperties outputProps = (TSnowflakeOutputProperties) getComponentService() .getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME); setupProps(outputProps.connection); outputProps.tableAction.setValue(TableAction.TableActionEnum.CREATE); String tableName = "TDI42854_" + testNumber; outputProps.table.tableName.setValue(tableName); Schema designSchema = SchemaBuilder.builder().record("design") .prop(SchemaConstants.INCLUDE_ALL_FIELDS, "true") .fields() .requiredString("staticColumn") .endRecord(); outputProps.table.main.schema.setValue(designSchema); Writer writer = makeWriter(outputProps); Schema runtimeSchema = SchemaBuilder.builder().record("runtime").fields() .requiredString("C1") .requiredString("C2") .requiredString("C3") .requiredString("STATICCOLUMN") .endRecord(); IndexedRecord record = new GenericData.Record(runtimeSchema); record.put(0, "c1_value"); record.put(1, "c2_value"); record.put(2, "c3_value"); record.put(3, "staticColumn_value"); try (Connection connection = DriverManagerUtils.getConnection(outputProps.connection)) { try { writeRows(writer, Collections.singletonList(record)); DatabaseMetaData metaData = connection.getMetaData(); try (ResultSet rs = metaData.getColumns(DB, testSchema, tableName, null)) { rs.next(); Assert.assertEquals("C1", rs.getString("COLUMN_NAME")); rs.next(); Assert.assertEquals("C2", rs.getString("COLUMN_NAME")); rs.next(); Assert.assertEquals("C3", rs.getString("COLUMN_NAME")); rs.next(); Assert.assertEquals("STATICCOLUMN", rs.getString("COLUMN_NAME")); Assert.assertFalse(rs.next()); } } finally { execute(connection, "drop table if exists " + tableName); } } }