manner commented on code in PR #29323:
URL: https://github.com/apache/flink/pull/29323#discussion_r4132778205


##########
flink-core/src/main/java/org/apache/flink/types/variant/BinaryVariantInternalBuilder.java:
##########
@@ -271,6 +276,33 @@ public void appendDecimal(BigDecimal d) {
         }
     }
 
+    // The variant spec requires a scale in [0, 38] and a precision of at most 
38.
+    private static BigDecimal toVariantDecimal(BigDecimal d) {
+        BigDecimal result = d;
+        if (d.scale() < 0) {
+            // A non-zero value with a scale below -38 has more than 38 digits 
after rescaling.
+            // Reject it upfront because setScale is expensive for huge 
exponents like 1e999999999.
+            if (d.signum() != 0 && d.scale() < -MAX_DECIMAL16_PRECISION) {

Review Comment:
   I added a helper `fitsVariantDecimal()` in `BinaryVariantUtil` that's now 
doing the precision and scale checking.



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