[fix](planner) SetOperationNode's slots' nullability calculation is wrong (#19108)

SetOperationNode's slots' nullability should consider slots info from all children, even some children have EmptyResultSet
This commit is contained in:
starocean999
2023-04-26 21:18:37 +08:00
committed by GitHub
parent 965682542d
commit aacc075f09
3 changed files with 53 additions and 1 deletions

View File

@ -219,7 +219,8 @@ public abstract class SetOperationNode extends PlanNode {
for (int j = 1; j < resultExprLists.size(); j++) {
isNullable = isNullable || resultExprLists.get(j).get(i).isNullable();
}
tupleDescriptor.getSlots().get(i).setIsNullable(isNullable);
tupleDescriptor.getSlots().get(i).setIsNullable(
tupleDescriptor.getSlots().get(i).getIsNullable() || isNullable);
tupleDescriptor.computeMemLayout();
}
}

View File

@ -2,3 +2,6 @@
-- !select --
1
-- !select2 --
9.0

View File

@ -54,4 +54,52 @@ suite("test_union_subquery_groupby") {
sql """
drop table if exists t_union_subquery_group_by;
"""
sql """
drop table if exists union_table_test;
"""
sql """
CREATE TABLE IF NOT EXISTS `union_table_test`
(
`dt` DATEV2 NOT NULL,
`label` VARCHAR(30) NOT NULL,
`uid_bitmap` BITMAP BITMAP_UNION NULL
)
AGGREGATE KEY (`dt`, `label`)
DISTRIBUTED BY HASH(`label`) BUCKETS AUTO
PROPERTIES
(
"replication_allocation" = "tag.location.default: 1"
);
"""
sql """
INSERT INTO union_table_test (dt, label, uid_bitmap) VALUES
('2023-04-01', 'new_user', bitmap_from_string("1,2,3,4,5,6,7,8,9"));
"""
qt_select2 """
SELECT
AVG(`source`.`uid_count`) AS `avg`
FROM (with temp1 AS
(SELECT dt,
label,
bitmap_count(uid_bitmap) AS uid_count
FROM union_table_test
UNION
all SELECT t1.dt,
'new/active' AS label, bitmap_count(t1.uid_bitmap) / bitmap_count(t1.uid_bitmap) AS uid_count
FROM union_table_test t1)
SELECT *
FROM temp1
) AS `source`
WHERE (`source`.`label` = 'new_user')
GROUP BY DATE(`source`.`dt`);
"""
sql """
drop table if exists union_table_test;
"""
}