Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public void prepareRun(BatchSourceContext context) {
@Override
public void initialize(BatchRuntimeContext context) throws Exception {
super.initialize(context);
SnowflakeSourceAccessor snowflakeAccessor = new SnowflakeSourceAccessor(config);
Schema schema = SchemaHelper.getSchema(snowflakeAccessor, config.getImportQuery());
Schema schema = SchemaHelper.getSchema(config, context.getFailureCollector());
this.transformer = new SnowflakeMapToRecordTransformer(schema);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,21 @@ public void testGetSchemaWhenMacroIsEnabledSchemaIsNull() {
Assert.assertNull(actual);

}

@Test
public void testGetSchemaManuallyUpdatedTheSchema() {
Schema expected = Schema.recordOf("test",
Schema.Field.of("test_field", Schema.nullableOf(Schema.of(Schema.Type.LONG)))
);

SnowflakeBatchSourceConfig mockConfig = Mockito.mock(SnowflakeBatchSourceConfig.class);
Mockito.when(mockConfig.canConnect()).thenReturn(false);
Mockito.when(mockConfig.getSchema()).thenReturn(expected.toString());

MockFailureCollector collector = new MockFailureCollector(MOCK_STAGE);
Schema actual = SchemaHelper.getSchema(mockConfig, collector);

Assert.assertTrue(collector.getValidationFailures().isEmpty());
Assert.assertEquals(expected, actual);
}
}