Skip to content

Commit

Permalink
[HUDI-4132] Fixing determining target table schema for delta sync wit…
Browse files Browse the repository at this point in the history
…h empty batch (apache#5648)
  • Loading branch information
nsivabalan authored and yihua committed Jun 3, 2022
1 parent e85b131 commit 723e54a
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -840,8 +840,15 @@ private Schema getSchemaForWriteConfig(Schema targetSchema) {
&& SchemaCompatibility.checkReaderWriterCompatibility(InputBatch.NULL_SCHEMA, targetSchema).getType() == SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE) {
// 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();
TableSchemaResolver schemaResolver = new TableSchemaResolver(meta);
newWriteSchema = schemaResolver.getTableAvroSchema(false);
int totalCompleted = meta.getActiveTimeline().getCommitsTimeline().filterCompletedInstants().countInstants();
if (totalCompleted > 0) {
try {
TableSchemaResolver schemaResolver = new TableSchemaResolver(meta);
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;
Expand Down

0 comments on commit 723e54a

Please sign in to comment.