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 (#5648)
  • Loading branch information
nsivabalan committed May 24, 2022
1 parent 0caa55e commit 10363c1
Showing 1 changed file with 9 additions and 2 deletions.
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 10363c1

Please sign in to comment.