ClickHouse / ClickHouse/ClickHouse

GROUPING function argument is not in GROUP BY keys for tuples with enable_analyzer=1

Open
#79,326 1 comment 0 reactions 1 assignee Claimed by @asya-ch View on GitHub
analyzer bug comp-query-analyzer external
Dominant language
C++
Stars
49.9k
Forks
9k
Avg merge
21h 32m
Merged PRs (30d)
515

Description

### Company or project name

_No response_

### Describe what's wrong

https://fiddle.clickhouse.com/a4f845df-81e3-4f49-9747-a1bbfbfa9712

```sql
SELECT
grouping(tt),
(number, number) AS tt,
count()
FROM numbers(10)
GROUP BY
GROUPING SETS (
(),
(tt))
SETTINGS enable_analyzer = 1

DB::Exception: GROUPING function argument (number, number) AS tt is not in GROUP BY keys.
```

With enable_analyzer=0 this query works fine.

Looks like tuples in some sense are not compatible with `grouping` function with new analyzer.

There is simple workaround. It is possible to replace `tt` in `grouping` and `GROUPING SETS` with tuple parameters: https://fiddle.clickhouse.com/a09e4073-7467-4e1b-b31b-bd13197225f4

But in any case, it looks like a bug.

### Does it reproduce on the most recent release?

Yes

### How to reproduce

Any recent ClickHouse, link to ClickHouse Playground can be found above.

### Expected behavior

_No response_

### Error message and/or stacktrace

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.