File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
main/java/io/cdap/plugin/snowflake/source/batch
test/java/io/cdap/plugin/snowflake/common/util Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -87,8 +87,7 @@ public void prepareRun(BatchSourceContext context) {
8787 @ Override
8888 public void initialize (BatchRuntimeContext context ) throws Exception {
8989 super .initialize (context );
90- SnowflakeSourceAccessor snowflakeAccessor = new SnowflakeSourceAccessor (config );
91- Schema schema = SchemaHelper .getSchema (snowflakeAccessor , config .getImportQuery ());
90+ Schema schema = SchemaHelper .getSchema (config , context .getFailureCollector ());
9291 this .transformer = new SnowflakeMapToRecordTransformer (schema );
9392 }
9493
Original file line number Diff line number Diff line change @@ -184,4 +184,21 @@ public void testGetSchemaWhenMacroIsEnabledSchemaIsNull() {
184184 Assert .assertNull (actual );
185185
186186 }
187+
188+ @ Test
189+ public void testGetSchemaManuallyUpdatedTheSchema () {
190+ Schema expected = Schema .recordOf ("test" ,
191+ Schema .Field .of ("test_field" , Schema .nullableOf (Schema .of (Schema .Type .LONG )))
192+ );
193+
194+ SnowflakeBatchSourceConfig mockConfig = Mockito .mock (SnowflakeBatchSourceConfig .class );
195+ Mockito .when (mockConfig .canConnect ()).thenReturn (false );
196+ Mockito .when (mockConfig .getSchema ()).thenReturn (expected .toString ());
197+
198+ MockFailureCollector collector = new MockFailureCollector (MOCK_STAGE );
199+ Schema actual = SchemaHelper .getSchema (mockConfig , collector );
200+
201+ Assert .assertTrue (collector .getValidationFailures ().isEmpty ());
202+ Assert .assertEquals (expected , actual );
203+ }
187204}
You can’t perform that action at this time.
0 commit comments