having item should be resolved to grouping expressions under rollup
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```
CREATE TABLE `sales` (
`year` int DEFAULT NULL,
`country` varchar(20) DEFAULT NULL,
`product` varchar(32) DEFAULT NULL,
`profit` int DEFAULT NULL
)
alter table sales set tiflash replica 1
SELECT year+2, SUM(profit) AS profit FROM sales GROUP BY year+2, year+profit WITH ROLLUP having year+2 > 2002;
```
### 2. What did you expect to see? (Required)
Spark does
```
== Optimized Logical Plan ==
Sort [(year + 2)#64 ASC NULLS FIRST, profit#62L ASC NULLS FIRST], true
+- Aggregate [(year#6 + 2)#68, (year#6 + profit#9)#69, spark_grouping_id#67L], [(year#6 + 2)#68 AS (year + 2)#64, sum(profit#9) AS profit#62L]
+- Filter (isnotnull((year#6 + 2)#68) AND ((year#6 + 2)#68 > 2002))
+- Expand [[profit#9, (year#6 + 2)#65, (year#6 + profit#9)#66, 0], [profit#9, (year#6 + 2)#65, null, 1], [profit#9, null, null, 3]], [profit#9, (year#6 + 2)#68, (year#6 + profit#9)#69, spark_grouping_id#67L]
+- Project [profit#9, (year#6 + 2) AS (year#6 + 2)#65, (year#6 + profit#9) AS (year#6 + profit#9)#66]
+- Relation spark_catalog.default.sales[year#6,country#7,product#8,profit#9] csv
```
### 3. What did you see instead (Required)
MySQL and TiDB does
```
mysql> SELECT year+2, SUM(profit) AS profit FROM sales GROUP BY year+2, year+profit WITH ROLLUP having year+2 > 2002;
ERROR 1054 (42S22): Unknown column 'year' in 'having clause'
```
### 4. What is your TiDB version? (Required)
Contributor guide
Assessment
This issue has not been assessed yet.