kasakrisz commented on code in PR #3964:
URL: https://github.com/apache/hive/pull/3964#discussion_r1073368036


##########
ql/src/java/org/apache/hadoop/hive/ql/io/parquet/convert/ETypeConverter.java:
##########
@@ -676,6 +676,39 @@ private int getScale(PrimitiveType type) {
               return logicalType.getScale();
             }
           };
+        case serdeConstants.VARCHAR_TYPE_NAME:
+          return new BinaryConverter<HiveVarcharWritable>(type, parent, index, 
hiveTypeInfo) {
+            @Override
+            protected HiveVarcharWritable convert(Binary binary) {
+              DecimalLogicalTypeAnnotation logicalType = 
(DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
+              HiveDecimalWritable decimalWritable = 
HiveDecimalUtils.enforcePrecisionScale(
+                      new HiveDecimalWritable(binary.getBytes(), 
logicalType.getScale()),
+                      new DecimalTypeInfo(logicalType.getPrecision(), 
logicalType.getScale()));

Review Comment:
   These 4 lines are the same in all the new cases. Could you please extract it?
   Exmaple
   ```
   abstract class BinaryConverterToCharacterType<T extends Writable> extends 
BinaryConverter<T> {
       protected byte[] convertToBytes(Binary binary) {
         DecimalLogicalTypeAnnotation logicalType = 
(DecimalLogicalTypeAnnotation) type.getLogicalTypeAnnotation();
         return HiveDecimalUtils.enforcePrecisionScale(
                 new HiveDecimalWritable(binary.getBytes(), 
logicalType.getScale()),
                 new DecimalTypeInfo(logicalType.getPrecision(), 
logicalType.getScale())).toString().getBytes();
       }
   
       protected abstract T convert(Binary binary);
   }
   ```
   and extend it and call `convertToBytes` in `convert`



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to