[HUDI-934] Add processing logic for the decimal LogicalType (#1677)
This commit is contained in:
@@ -26,6 +26,7 @@ import org.apache.hudi.common.util.collection.Pair;
|
|||||||
import org.apache.hudi.exception.HoodieException;
|
import org.apache.hudi.exception.HoodieException;
|
||||||
import org.apache.hudi.exception.HoodieIOException;
|
import org.apache.hudi.exception.HoodieIOException;
|
||||||
|
|
||||||
|
import org.apache.avro.LogicalTypes;
|
||||||
import org.apache.avro.Schema;
|
import org.apache.avro.Schema;
|
||||||
import org.apache.avro.Schema.Field;
|
import org.apache.avro.Schema.Field;
|
||||||
import org.apache.avro.generic.GenericArray;
|
import org.apache.avro.generic.GenericArray;
|
||||||
@@ -36,6 +37,7 @@ import org.apache.hadoop.fs.Path;
|
|||||||
import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
|
import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
|
||||||
import org.apache.hadoop.hive.serde2.ColumnProjectionUtils;
|
import org.apache.hadoop.hive.serde2.ColumnProjectionUtils;
|
||||||
import org.apache.hadoop.hive.serde2.io.DoubleWritable;
|
import org.apache.hadoop.hive.serde2.io.DoubleWritable;
|
||||||
|
import org.apache.hadoop.hive.serde2.io.HiveDecimalWritable;
|
||||||
import org.apache.hadoop.io.ArrayWritable;
|
import org.apache.hadoop.io.ArrayWritable;
|
||||||
import org.apache.hadoop.io.BooleanWritable;
|
import org.apache.hadoop.io.BooleanWritable;
|
||||||
import org.apache.hadoop.io.BytesWritable;
|
import org.apache.hadoop.io.BytesWritable;
|
||||||
@@ -300,6 +302,14 @@ public abstract class AbstractRealtimeRecordReader {
|
|||||||
throw new IllegalArgumentException("Only support union with null");
|
throw new IllegalArgumentException("Only support union with null");
|
||||||
}
|
}
|
||||||
case FIXED:
|
case FIXED:
|
||||||
|
if (schema.getLogicalType() != null && schema.getLogicalType().getName().equals("decimal")) {
|
||||||
|
LogicalTypes.Decimal decimal = (LogicalTypes.Decimal) LogicalTypes.fromSchema(schema);
|
||||||
|
HiveDecimalWritable writable = new HiveDecimalWritable(((GenericFixed) value).bytes(),
|
||||||
|
decimal.getScale());
|
||||||
|
return HiveDecimalWritable.enforcePrecisionScale(writable,
|
||||||
|
decimal.getPrecision(),
|
||||||
|
decimal.getScale());
|
||||||
|
}
|
||||||
return new BytesWritable(((GenericFixed) value).bytes());
|
return new BytesWritable(((GenericFixed) value).bytes());
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user