hudi 0.13.0适配hive3修改点
编译报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project hudi-hadoop-mr: Compilation failure: Compilation failure:
[ERROR] /root/bigdata/hudi/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HiveAvroSerializer.java:[302,93] incompatible types: org.apache.hadoop.hive.common.type.Date cannot be converted to java.sql.Date
[ERROR] /root/bigdata/hudi/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HiveAvroSerializer.java:[305,72] incompatible types: org.apache.hadoop.hive.common.type.Timestamp cannot be converted to java.sql.Timestamp
[ERROR] /root/bigdata/hudi/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HiveAvroSerializer.java:[309,98] incompatible types: org.apache.hadoop.hive.common.type.Date cannot be converted to java.sql.Date
代码修改,
301-310行从
case DATE:
return DateWritable.dateToDays(((DateObjectInspector)fieldOI).getPrimitiveJavaObject(structFieldData));
case TIMESTAMP:
Timestamp timestamp =
((TimestampObjectInspector) fieldOI).getPrimitiveJavaObject(structFieldData);
return timestamp.getTime();
case INT:
if (schema.getLogicalType() != null && schema.getLogicalType().getName().equals("date")) {
return DateWritable.dateToDays(new WritableDateObjectInspector().getPrimitiveJavaObject(structFieldData));
}
修改为
case DATE:
return ((DateObjectInspector)fieldOI).getPrimitiveJavaObject(structFieldData).toEpochDay();
case TIMESTAMP:
Timestamp timestamp =
((TimestampObjectInspector) fieldOI).getPrimitiveJavaObject(structFieldData).toSqlTimestamp();
return timestamp.getTime();
case INT:
if (schema.getLogicalType() != null && schema.getLogicalType().getName().equals("date")) {
return new WritableDateObjectInspector().getPrimitiveJavaObject(structFieldData).toEpochDay();
}