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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DecimalV2Type.java:
##########
@@ -249,4 +252,8 @@ public int width() {
         return WIDTH;
     }
 
+    @Override
+    public Optional<Expression> defaultValue() {
+        return Optional.of(new DecimalLiteral(this, BigDecimal.ZERO));

Review Comment:
   [P2] Scale decimal zero before validating the default literal
   
   `DecimalV2Type.createDecimalV2Type(9, 9).defaultValue()` throws 
`AnalysisException` instead of returning zero. `BigDecimal.ZERO` has precision 
1 and scale 0, and `DecimalLiteral.checkPrecisionAndScale` validates it before 
the constructor rescales it, so its integer width (1) exceeds `precision - 
scale` (0). This affects valid `DECIMALV2(p,p)` defaults requested through the 
new API; the former `IntegerLiteral(0).castTo(type)` scaled zero first. 
Construct zero at `getScale()` before passing it to `DecimalLiteral`, and cover 
the precision-equals-scale case. This is an API-contract defect; the current 
IVM hidden-slot path does not produce decimal columns.



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