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


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/BindSink.java:
##########
@@ -563,6 +563,9 @@ private static Map<String, NamedExpression> 
getColumnToOutput(
                     boundExpression = ((Alias) boundExpression).child();
                 }
                 boundExpression = ExpressionUtils.replace(boundExpression, 
replaceMap);
+                // Dependent generated columns must use the value converted to 
this column's declared type.
+                boundExpression = 
TypeCoercionUtils.castIfNotSameType(boundExpression,

Review Comment:
   [P1] Apply the actual string-width coercion before dependency substitution
   
   This still skips the declared-type conversion whenever both sides are 
string-like: `castIfNotSameType` returns its input unchanged for all 
CHAR/VARCHAR/STRING pairs, while `getOutputProjectByCoercion` only later 
truncates an over-width value. For a legal table `a VARCHAR(10), c VARCHAR(2) 
AS (a), d INT AS (length(c))` and input `'abcd'`, the produced shape is:
   
   ```text
   Sink
     Project(c=substring(c_slot, 1, 2), d=d_slot)
       Project(c=a, d=length(a))
         Input(a='abcd')
   ```
   
   The sink therefore receives `c='ab'` and `d=4`, although evaluating 
`length(c)` from the stored row gives 2. Please apply the same string 
coercion/truncation semantics before registering the generated alias in 
`replaceMap`, and add an over-width string dependency regression.



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