[HUDI-1302] Add support for timestamp field in HiveSync (#2129)
This commit is contained in:
@@ -68,6 +68,9 @@ public class DLASyncConfig implements Serializable {
|
||||
@Parameter(names = {"--help", "-h"}, help = true)
|
||||
public Boolean help = false;
|
||||
|
||||
@Parameter(names = {"--support-timestamp"}, description = "If true, converts int64(timestamp_micros) to timestamp type")
|
||||
public Boolean supportTimestamp = false;
|
||||
|
||||
public static DLASyncConfig copy(DLASyncConfig cfg) {
|
||||
DLASyncConfig newConfig = new DLASyncConfig();
|
||||
newConfig.databaseName = cfg.databaseName;
|
||||
@@ -81,6 +84,7 @@ public class DLASyncConfig implements Serializable {
|
||||
newConfig.assumeDatePartitioning = cfg.assumeDatePartitioning;
|
||||
newConfig.skipROSuffix = cfg.skipROSuffix;
|
||||
newConfig.useDLASyncHiveStylePartitioning = cfg.useDLASyncHiveStylePartitioning;
|
||||
newConfig.supportTimestamp = cfg.supportTimestamp;
|
||||
return newConfig;
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ public class DLASyncTool extends AbstractSyncTool {
|
||||
} else {
|
||||
// Check if the table schema has evolved
|
||||
Map<String, String> tableSchema = hoodieDLAClient.getTableSchema(tableName);
|
||||
SchemaDifference schemaDiff = HiveSchemaUtil.getSchemaDifference(schema, tableSchema, cfg.partitionFields);
|
||||
SchemaDifference schemaDiff = HiveSchemaUtil.getSchemaDifference(schema, tableSchema, cfg.partitionFields, cfg.supportTimestamp);
|
||||
if (!schemaDiff.isEmpty()) {
|
||||
LOG.info("Schema difference found for " + tableName);
|
||||
hoodieDLAClient.updateTableDefinition(tableName, schemaDiff);
|
||||
|
||||
@@ -50,5 +50,6 @@ public class TestDLASyncConfig {
|
||||
assertEquals(copied.basePath, dlaSyncConfig.basePath);
|
||||
assertEquals(copied.jdbcUrl, dlaSyncConfig.jdbcUrl);
|
||||
assertEquals(copied.skipROSuffix, dlaSyncConfig.skipROSuffix);
|
||||
assertEquals(copied.supportTimestamp, dlaSyncConfig.supportTimestamp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user