Skip to content

Commit

Permalink
Fixing determining target table schema for delta sync with empty batch
Browse files Browse the repository at this point in the history
  • Loading branch information
nsivabalan committed May 23, 2022
1 parent 6f37863 commit fa11e50
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 fa11e50

Please sign in to comment.