924060929 opened a new pull request, #69388:
URL: https://github.com/apache/doris/pull/69388
### What problem does this PR solve?
Issue Number: N/A
Related PR: #64718
A qualified reference to a preserved-side USING key can be rejected even
when the same key appears unqualified in GROUP BY. For example:
```sql
SELECT t1.a, COUNT(*)
FROM t1 LEFT JOIN t2 USING(a)
GROUP BY a;
```
The USING-key projection creates a fresh Alias for a column forwarded
directly from the preserved side. SELECT t1.a then references the original
ExprId while GROUP BY a references the new one. Aggregate analysis rejects the
query. The same mismatch affects HAVING and ORDER BY.
Keep the input ExprId for forwarded USING keys while clearing the qualifier
of the unqualified view. Preserve the original qualified outputs and the
explicit asterisk output list. FULL OUTER JOIN still builds a new COALESCE
expression with its own ExprId, and aggregate validation remains unchanged.
### Release note
Fix spurious GROUP BY errors when qualified and unqualified references to a
forwarded USING join key are mixed in SELECT, GROUP BY, HAVING, or ORDER BY.
### Check List (For Author)
- Test: Unit Test
- Complete BindUsingJoinTest suite passed through ./run-fe-ut.sh: 29
tests, 0 failures/errors.
- Added complete-planner cases for both reference directions, HAVING/ORDER
BY, compound grouping expressions, multiple USING keys, and derived inputs
across INNER, LEFT/RIGHT, and SEMI/ANTI joins.
- Existing coverage checks star expansion, qualified stars, chained joins,
and FULL OUTER COALESCE keys; negative cases keep nullable-side and FULL OUTER
key validation intact.
- Added an EXPLAIN regression case to test_using_join_merge_key; its SQL
is also exercised by the FE full-planner unit test. The regression suite itself
has not been run locally.
- Checkstyle and git diff --check.
- Behavior changed: Yes, valid grouping queries now plan successfully.
- Does this need documentation: No.
--
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]