Fix NPE when offline compaction could not find schema from data file
This commit is contained in:
@@ -127,10 +127,14 @@ public class CompactionUtil {
|
|||||||
* @param conf The configuration
|
* @param conf The configuration
|
||||||
*/
|
*/
|
||||||
public static void inferChangelogMode(Configuration conf, HoodieTableMetaClient metaClient) throws Exception {
|
public static void inferChangelogMode(Configuration conf, HoodieTableMetaClient metaClient) throws Exception {
|
||||||
TableSchemaResolver tableSchemaResolver = new TableSchemaResolver(metaClient);
|
try {
|
||||||
Schema tableAvroSchema = tableSchemaResolver.getTableAvroSchemaFromDataFile();
|
TableSchemaResolver tableSchemaResolver = new TableSchemaResolver(metaClient);
|
||||||
if (tableAvroSchema.getField(HoodieRecord.OPERATION_METADATA_FIELD) != null) {
|
Schema tableAvroSchema = tableSchemaResolver.getTableAvroSchemaFromDataFile();
|
||||||
conf.setBoolean(FlinkOptions.CHANGELOG_ENABLED, true);
|
if (tableAvroSchema.getField(HoodieRecord.OPERATION_METADATA_FIELD) != null) {
|
||||||
|
conf.setBoolean(FlinkOptions.CHANGELOG_ENABLED, true);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.warn("Could not get schema from data file, CHANGELOG_ENABLE is set to default", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user