[HUDI-2184] Support setting hive sync partition extractor class based on flink configuration (#3284)
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
package org.apache.hudi.table;
|
||||
|
||||
import org.apache.hudi.configuration.FlinkOptions;
|
||||
import org.apache.hudi.hive.MultiPartKeysValueExtractor;
|
||||
import org.apache.hudi.keygen.ComplexAvroKeyGenerator;
|
||||
import org.apache.hudi.keygen.NonpartitionedAvroKeyGenerator;
|
||||
import org.apache.hudi.util.AvroSchemaConverter;
|
||||
@@ -148,6 +149,8 @@ public class HoodieTableFactory implements DynamicTableSourceFactory, DynamicTab
|
||||
setupHoodieKeyOptions(conf, table);
|
||||
// compaction options
|
||||
setupCompactionOptions(conf);
|
||||
// hive options
|
||||
setupHiveOptions(conf);
|
||||
// infer avro schema from physical DDL schema
|
||||
inferAvroSchema(conf, schema.toRowDataType().notNull().getLogicalType());
|
||||
}
|
||||
@@ -207,6 +210,16 @@ public class HoodieTableFactory implements DynamicTableSourceFactory, DynamicTab
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the hive options from the table definition.
|
||||
* */
|
||||
private static void setupHiveOptions(Configuration conf) {
|
||||
if (!conf.getBoolean(FlinkOptions.HIVE_STYLE_PARTITIONING)
|
||||
&& FlinkOptions.isDefaultValueDefined(conf, FlinkOptions.HIVE_SYNC_PARTITION_EXTRACTOR_CLASS)) {
|
||||
conf.setString(FlinkOptions.HIVE_SYNC_PARTITION_EXTRACTOR_CLASS, MultiPartKeysValueExtractor.class.getName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Inferences the deserialization Avro schema from the table schema (e.g. the DDL)
|
||||
* if both options {@link FlinkOptions#SOURCE_AVRO_SCHEMA_PATH} and
|
||||
|
||||
Reference in New Issue
Block a user