924060929 opened a new pull request, #64458:
URL: https://github.com/apache/doris/pull/64458
### What problem does this PR solve?
Problem Summary:
Under `only_full_group_by` (the default), Nereids rejected any
non-aggregated select
expression that was neither in `GROUP BY` nor wrapped in an aggregate
function, even when
that expression is **constant for every input row**. MySQL accepts such
expressions via
functional dependency. For example:
```sql
SELECT a AS b, b AS c FROM (SELECT 1 AS a, 2 AS b) t1 GROUP BY b, c;
```
The output alias `b` collides with the derived-table column `b`, so
column-first name
resolution groups by the column `b` and leaves the constant column `a`
ungrouped. This
previously failed with:
```
PROJECT expression 'a' must appear in the GROUP BY clause or be used in an
aggregate function
```
`NormalizeAggregate` now only rejects **non-constant** missing slots.
Constant (uniform)
slots flow through the existing `any_value()` wrapping (any_value of a
constant is that
constant), so the result stays unambiguous and the query returns `(1, 2)`,
matching MySQL.
The same shape over a real table, where the ungrouped column is
non-constant, is still
rejected.
### Release note
Allow a constant (uniform) non-aggregated column that is not in `GROUP BY`
under
`only_full_group_by`, matching MySQL functional-dependency behavior.
### Check List (For Author)
- Test
- [x] Regression test
- [x] Unit Test
- Behavior changed:
- [x] Yes. A constant column that is neither grouped nor used in an
aggregate is now
accepted under `only_full_group_by` (previously rejected).
Non-constant columns are
still rejected.
- Does this need documentation?
- [x] 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]