voonhous commented on code in PR #17581:
URL: https://github.com/apache/hudi/pull/17581#discussion_r2644069314
##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HiveTypeUtils.java:
##########
@@ -134,33 +146,25 @@ protected TypeInfo makeInstance(Schema s,
* @return TypeInfo matching the Avro schema
* @throws AvroSerdeException for any problems during conversion.
*/
- public static TypeInfo generateTypeInfo(Schema schema,
- Set<Schema> seenSchemas) throws
AvroSerdeException {
+ public static TypeInfo generateTypeInfo(HoodieSchema schema,
+ Set<HoodieSchema> seenSchemas)
throws AvroSerdeException {
// For bytes type, it can be mapped to decimal.
- Schema.Type type = schema.getType();
- // HUDI MODIFICATION ADDED "|| type == FIXED"
- if ((type == BYTES || type == FIXED) && AvroSerDe.DECIMAL_TYPE_NAME
- .equalsIgnoreCase(schema.getProp(AvroSerDe.AVRO_PROP_LOGICAL_TYPE))) {
- int precision = 0;
- int scale = 0;
- try {
- precision =
getIntValue(schema.getObjectProp(AvroSerDe.AVRO_PROP_PRECISION));
- scale = getIntValue(schema.getObjectProp(AvroSerDe.AVRO_PROP_SCALE));
- } catch (Exception ex) {
- throw new AvroSerdeException("Failed to obtain scale value from file
schema: " + schema, ex);
- }
-
+ HoodieSchemaType type = schema.getType();
+ if (type == DECIMAL && AvroSerDe.DECIMAL_TYPE_NAME
+ .equalsIgnoreCase((String)
schema.getProp(AvroSerDe.AVRO_PROP_LOGICAL_TYPE))) {
Review Comment:
Yeap, it's doable for all the types in this function except `VARCHAR` and
`CHAR`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]