You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/12/22 08:04:58 UTC
[GitHub] [hudi] danny0405 commented on a change in pull request #4421: [HUDI-3096] fixed the bug that the cow table(contains decimalType) wriite by flink cannot be read by spark.
danny0405 commented on a change in pull request #4421:
URL: https://github.com/apache/hudi/pull/4421#discussion_r773676079
##########
File path: hudi-flink/src/main/java/org/apache/hudi/util/AvroSchemaConverter.java
##########
@@ -244,10 +244,13 @@ public static Schema convertToSchema(LogicalType logicalType, String rowName) {
return nullable ? nullableSchema(time) : time;
case DECIMAL:
DecimalType decimalType = (DecimalType) logicalType;
- // store BigDecimal as byte[]
+ // store BigDecimal as Fixed
+ // for spark compatibility.
Schema decimal =
LogicalTypes.decimal(decimalType.getPrecision(), decimalType.getScale())
- .addToSchema(SchemaBuilder.builder().bytesType());
+ .addToSchema(SchemaBuilder
+ .fixed(String.format("%s.fixed", rowName))
+ .size(computeMinBytesForDecimlPrecision(decimalType.getPrecision())));
Review comment:
Thanks for the fix, can this type be read through Hive directly ? There is also some type compatibility for Spark & Hive decimal types.
--
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: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org