hudi-agent commented on code in PR #20130:
URL: https://github.com/apache/hudi/pull/20130#discussion_r4127557271


##########
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/client/utils/SparkInternalSchemaConverter.java:
##########
@@ -349,9 +349,13 @@ private static boolean 
convertIntLongType(WritableColumnVector oldV, WritableCol
         } else if (newType instanceof StringType) {
           newV.putByteArray(i, getUTF8Bytes((isInt ? oldV.getInt(i) : 
oldV.getLong(i)) + ""));
         } else if (newType instanceof DecimalType) {
+          DecimalType decimalType = (DecimalType) newType;
           Decimal oldDecimal = Decimal.apply(isInt ? oldV.getInt(i) : 
oldV.getLong(i));
-          oldDecimal.changePrecision(((DecimalType) newType).precision(), 
((DecimalType) newType).scale());
-          newV.putDecimal(i, oldDecimal, ((DecimalType) newType).precision());
+          if (oldDecimal.changePrecision(decimalType.precision(), 
decimalType.scale())) {

Review Comment:
   🤖 The same unchecked `changePrecision()` pattern is still in 
`convertFloatType`, `convertDoubleType` and `convertStringType` 
(FLOAT/DOUBLE/STRING -> DECIMAL). For example, a float `12345.0` read as 
`decimal(4,2)` should still come back as a wrong value. `SchemaChangeUtils` 
allows all of these evolutions. Could you apply the same NULL fallback there, 
and maybe add a float/double case to the test?
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



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

Reply via email to