File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
hudi-utilities/src/main/java/org/apache/hudi/utilities/deltastreamer Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -840,8 +840,15 @@ private Schema getSchemaForWriteConfig(Schema targetSchema) {
840840 && SchemaCompatibility .checkReaderWriterCompatibility (InputBatch .NULL_SCHEMA , targetSchema ).getType () == SchemaCompatibility .SchemaCompatibilityType .COMPATIBLE ) {
841841 // target schema is null. fetch schema from commit metadata and use it
842842 HoodieTableMetaClient meta = HoodieTableMetaClient .builder ().setConf (new Configuration (fs .getConf ())).setBasePath (cfg .targetBasePath ).setPayloadClassName (cfg .payloadClassName ).build ();
843- TableSchemaResolver schemaResolver = new TableSchemaResolver (meta );
844- newWriteSchema = schemaResolver .getTableAvroSchema (false );
843+ int totalCompleted = meta .getActiveTimeline ().getCommitsTimeline ().filterCompletedInstants ().countInstants ();
844+ if (totalCompleted > 0 ) {
845+ try {
846+ TableSchemaResolver schemaResolver = new TableSchemaResolver (meta );
847+ newWriteSchema = schemaResolver .getTableAvroSchema (false );
848+ } catch (IllegalArgumentException e ) {
849+ LOG .warn ("Could not fetch schema from table. Falling back to using target schema from schema provider" );
850+ }
851+ }
845852 }
846853 }
847854 return newWriteSchema ;
You can’t perform that action at this time.
0 commit comments