github-actions[bot] commented on code in PR #66967:
URL: https://github.com/apache/doris/pull/66967#discussion_r3840245513
##########
fe/fe-sql-parser/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4:
##########
@@ -1838,7 +1838,7 @@ constant
| booleanValue
#booleanLiteral
| BINARY? STRING_LITERAL
#stringLiteral
| VARBINARY_LITERAL
#varbinaryLiteral
- | LEFT_BRACKET (items+=constant)? (COMMA items+=constant)* RIGHT_BRACKET
#arrayLiteral
+ | LEFT_BRACKET (items+=expression)? (COMMA items+=expression)*
RIGHT_BRACKET #arrayLiteral
Review Comment:
[P1] Keep expression-valued arrays out of literal-only constant callers
This alternative is still part of the shared `constant` rule, but
`visitArrayLiteral` now returns scalar `Array` for a non-literal constant item.
Existing parents such as `visitMapLiteral` and `visitStructLiteral` still
consume `constant` children as `Literal`, while OUTFILE and SET_VAR explicitly
cast the result; for example, `SELECT {1: [CAST(2 AS INT)]}` reaches an
unchecked internal runtime type failure before analysis. Please either separate
bracket-array expressions from the literal-valued `constant` rule or update
every consumer to handle `Expression` and reject unsupported contexts with a
controlled error, and add a nested parser case.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -3800,12 +3801,30 @@ private List<Literal> typeCoercionItems(List<Literal>
items) {
}
@Override
- public ArrayLiteral visitArrayLiteral(ArrayLiteralContext ctx) {
- List<Literal> items =
ctx.items.stream().<Literal>map(this::typedVisit).collect(Collectors.toList());
+ public Expression visitArrayLiteral(ArrayLiteralContext ctx) {
+ List<Expression> items =
ctx.items.stream().<Expression>map(this::typedVisit).collect(Collectors.toList());
if (items.isEmpty()) {
- return new ArrayLiteral(items);
+ return new ArrayLiteral(ImmutableList.of());
+ }
+ for (Expression item : items) {
Review Comment:
[P1] Validate array-item constantness after function binding
At this point ordinary calls are still `UnboundFunction`, which defaults to
deterministic and is neither an `AggregateFunction` nor a
`TableGeneratingFunction`. As a result, `[random()]` and `[sum(1)]` pass this
guard; binding later turns them into a volatile function and an aggregate, but
line 3820 has already lowered the bracket expression to a normal scalar `Array`
and no bracket-specific check runs again. This lets constant-only syntax vary
per row or depend on group cardinality. Please preserve the bracket-array
origin through analysis and validate the bound items before lowering, with
analyzed negative tests for these late-bound cases.
--
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]