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 @@ -182,4 +182,21 @@ public void testGetSchemaWhenMacroIsEnabledSchemaIsNull() {
182182 Assert .assertNull (actual );
183183
184184 }
185+
186+ @ Test
187+ public void testGetSchemaManuallyUpdatedTheSchema () {
188+ Schema expected = Schema .recordOf ("test" ,
189+ Schema .Field .of ("test_field" , Schema .nullableOf (Schema .of (Schema .Type .LONG )))
190+ );
191+
192+ SnowflakeBatchSourceConfig mockConfig = Mockito .mock (SnowflakeBatchSourceConfig .class );
193+ Mockito .when (mockConfig .canConnect ()).thenReturn (false );
194+ Mockito .when (mockConfig .getSchema ()).thenReturn (expected .toString ());
195+
196+ MockFailureCollector collector = new MockFailureCollector (MOCK_STAGE );
197+ Schema actual = SchemaHelper .getSchema (mockConfig , collector );
198+
199+ Assert .assertTrue (collector .getValidationFailures ().isEmpty ());
200+ Assert .assertEquals (expected , actual );
201+ }
185202}
You can’t perform that action at this time.
0 commit comments