[fix](fe)predicate is wrongly pushed through CUBE function (#15831)
This commit is contained in:
@ -2667,8 +2667,10 @@ public class SingleNodePlanner {
|
||||
//eg: select distinct c from ( select distinct c from table) t where c > 1;
|
||||
continue;
|
||||
}
|
||||
if (stmt.getGroupByClause().isGroupByExtension()
|
||||
&& stmt.getGroupByClause().getGroupingExprs().contains(sourceExpr)) {
|
||||
|
||||
if (sourceExpr.getFn() instanceof AggregateFunction) {
|
||||
isAllSlotReferToGroupBys = false;
|
||||
} else if (stmt.getGroupByClause().isGroupByExtension()) {
|
||||
// if grouping type is CUBE or ROLLUP will definitely produce null
|
||||
if (stmt.getGroupByClause().getGroupingType() == GroupByClause.GroupingType.CUBE
|
||||
|| stmt.getGroupByClause().getGroupingType() == GroupByClause.GroupingType.ROLLUP) {
|
||||
@ -2684,9 +2686,6 @@ public class SingleNodePlanner {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sourceExpr.getFn() instanceof AggregateFunction) {
|
||||
isAllSlotReferToGroupBys = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isAllSlotReferToGroupBys) {
|
||||
|
||||
@ -49,3 +49,6 @@
|
||||
|
||||
-- !select7 --
|
||||
|
||||
-- !select8 --
|
||||
test 2
|
||||
|
||||
|
||||
@ -60,4 +60,22 @@ suite("test_grouping_sets") {
|
||||
}
|
||||
|
||||
qt_select7 """ select k1,k2,sum(k3) from test_query_db.test where 1 = 2 group by grouping sets((k1), (k1,k2)) """
|
||||
|
||||
qt_select8 """ WITH dt AS
|
||||
(select 'test' as name,1 as score
|
||||
UNION
|
||||
all
|
||||
SELECT 'test' AS name,1 AS score
|
||||
UNION
|
||||
all SELECT 'test2' AS name,12 AS score
|
||||
UNION
|
||||
all SELECT 'test2' AS name,12 AS score ) ,result_data AS
|
||||
(SELECT name,
|
||||
sum(score) AS score
|
||||
FROM dt
|
||||
GROUP BY CUBE(name))
|
||||
SELECT *
|
||||
FROM result_data
|
||||
WHERE name = 'test';
|
||||
"""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user