Hello calcite team,

Consider the following:
Let's say I have a table "t" with two columns:
"CREATE TABLE t(x int, y int);"

Now, the following query will result in validation error:
"SELECT * FROM t GROUP BY 1,2",
But if I'm not using "*" it will work:
"SELECT x, y FROM t GROUP BY 1,2"

The issue is that the group by validation happens before we do star
expansion.
Note that ORDER BY doesn't have the same issue, as the ORDER BY validation
happens after star expansion.

The star expansion is done inside `ValidateSelectList`, and there is a
comment above stating that:

>     // Validate the SELECT clause late, because a select item might
>     // depend on the GROUP BY list, or the window function might reference
>     // window name in the WINDOW clause etc.
>

Given that I have 3 questions: Is the issue above a bug?
If so, can we do the star expansion before the GROUP BY validation?
And when can a select item is depends on the GROUP BY list?

Thanks,
Itiel

Reply via email to