github-actions[bot] commented on code in PR #64026:
URL: https://github.com/apache/doris/pull/64026#discussion_r3411609553


##########
fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExprUtils.java:
##########
@@ -85,6 +92,48 @@ public static LiteralExpr createLiteral(String value, Type 
type) throws Analysis
         return literalExpr;
     }
 
+    private static LiteralExpr createFloatingPointLiteral(String value, Type 
type) throws AnalysisException {
+        try {
+            return new FloatLiteral(Double.parseDouble(value), type);
+        } catch (NumberFormatException e) {
+            throw new AnalysisException("Invalid floating-point literal: " + 
value, e);
+        }
+    }
+
+    private static LiteralExpr createDecimalLiteral(String value, Type type) 
throws AnalysisException {
+        Preconditions.checkArgument(type instanceof ScalarType,
+                String.format("%s's type %s is not ScalarType", value, type));
+        ScalarType scalarType = (ScalarType) type;
+        BigDecimal decimalValue;
+        try {
+            decimalValue = new BigDecimal(value);
+        } catch (NumberFormatException e) {
+            throw new AnalysisException("Invalid decimal literal: " + value, 
e);
+        }
+        // Do not silently round partition boundary values. If a user specifies

Review Comment:
   The earlier rounding problem is fixed by rejecting extra scale, but this 
predicate is now too strict for exact values with trailing zeros. For a 
`DECIMAL(10,2)` partition column, `VALUES LESS THAN ('10.000')` is exactly 
representable as `10.00`; no rounding or boundary change is required. 
`BigDecimal("10.000").scale()` is `3`, so this path throws before building the 
typed `DecimalLiteral`.
   
   Please reject only cases where reducing to the column scale would require 
rounding, for example by using `setScale(targetScale, 
RoundingMode.UNNECESSARY)` or by stripping trailing zeros before comparing 
scale, and add a DECIMAL partition test for the trailing-zero case.



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