[HUDI-4132] Fixing determining target table schema for delta sync with empty batch (#5648)
This commit is contained in:
committed by
GitHub
parent
0caa55ecb4
commit
10363c1412
@@ -840,8 +840,15 @@ public class DeltaSync implements Serializable {
|
|||||||
&& SchemaCompatibility.checkReaderWriterCompatibility(InputBatch.NULL_SCHEMA, targetSchema).getType() == SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE) {
|
&& SchemaCompatibility.checkReaderWriterCompatibility(InputBatch.NULL_SCHEMA, targetSchema).getType() == SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE) {
|
||||||
// target schema is null. fetch schema from commit metadata and use it
|
// target schema is null. fetch schema from commit metadata and use it
|
||||||
HoodieTableMetaClient meta = HoodieTableMetaClient.builder().setConf(new Configuration(fs.getConf())).setBasePath(cfg.targetBasePath).setPayloadClassName(cfg.payloadClassName).build();
|
HoodieTableMetaClient meta = HoodieTableMetaClient.builder().setConf(new Configuration(fs.getConf())).setBasePath(cfg.targetBasePath).setPayloadClassName(cfg.payloadClassName).build();
|
||||||
|
int totalCompleted = meta.getActiveTimeline().getCommitsTimeline().filterCompletedInstants().countInstants();
|
||||||
|
if (totalCompleted > 0) {
|
||||||
|
try {
|
||||||
TableSchemaResolver schemaResolver = new TableSchemaResolver(meta);
|
TableSchemaResolver schemaResolver = new TableSchemaResolver(meta);
|
||||||
newWriteSchema = schemaResolver.getTableAvroSchema(false);
|
newWriteSchema = schemaResolver.getTableAvroSchema(false);
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
LOG.warn("Could not fetch schema from table. Falling back to using target schema from schema provider");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newWriteSchema;
|
return newWriteSchema;
|
||||||
|
|||||||
Reference in New Issue
Block a user