github-actions[bot] commented on code in PR #70499:
URL: https://github.com/apache/doris/pull/70499#discussion_r4547606144
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/check/CheckCast.java:
##########
@@ -418,8 +416,7 @@ public static boolean check(DataType originalType, DataType
targetType,
if (looseAggState && originalType instanceof AggStateType &&
targetType instanceof AggStateType) {
AggStateType originalAggState = (AggStateType) originalType;
AggStateType targetAggState = (AggStateType) targetType;
- if (originalAggState.isLooseTypeCoercionAllowed()
- &&
originalAggState.getFunctionName().equalsIgnoreCase(targetAggState.getFunctionName())
+ if
(originalAggState.getFunctionName().equalsIgnoreCase(targetAggState.getFunctionName())
Review Comment:
[P1] Validate state casts inside guarded MERGE assignments
Removing this admission guard relies on every cast reaching the final
checker, but MERGE assignments are wrapped by `generateFinalProjections` in
`ShortCircuitIf`, whose children `ExpressionBottomUpRewriter` deliberately
skips. For a MoW target with `s agg_state<min(bigint not null)>` (allowed by
`enable_non_aggregate_table_state_types=true`), use a grouped source `SELECT k,
min_combine(d) AS s FROM src GROUP BY k`, where `d` is `DOUBLE NOT NULL`, and
clauses `WHEN MATCHED AND t.k > 0 THEN UPDATE SET s=q.s WHEN MATCHED THEN
UPDATE SET s=t.s`:
```text
Project(ShortCircuitIf(branch_label=0,
Cast(q.s:min(DOUBLE) AS min(BIGINT)), other_branch))
Join(target, Aggregate(k, min_combine(d) AS s) / Scan(src))
```
The source slot preserves the combine type, so the old guard rejected this
cast while binding. It is now admitted, remains hidden from `CheckCast`, and
neither `CheckAfterRewrite` nor translation checks it. This can write an
incompatible state: BE unwraps both numeric MIN types to
`DataTypeFixedLengthObject` and identity-casts the bytes, while MIN's state
contains the original typed value and storage persists those bytes. A DOUBLE
state is therefore stored as a BIGINT state without converting its value.
Ensure a non-evaluating final validation pass reaches guarded branches after
producer conversion, and add a MERGE regression before relaxing the early check.
--
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]