[test](regression) Add left join not-null column pruning regression test ### What problem does this PR solve? Issue Number: None Related PR: #66380 Problem Summary: Add the left_join_not_null_column regression suite to verify that a physical NOT NULL column (right-side dimension column of a LEFT JOIN) made nullable only by the outer join does not get a NULL-only access path ([col, NULL]) from IS NULL, which would make the BE read the null map of a NOT NULL column and crash with an is_column_nullable check failure. On the current meta-path branch this is handled by the hasPhysicalNullMap check in AccessPathExpressionCollector (slot-finalization level), so the suite passes: EXPLAIN contains no segment.NULL and the query returns (3, 6, 60, 600.00, 1). ### Release note None ### Check List (For Author) - Test: Regression test (left_join_not_null_column) passed on meta-path branch - Behavior changed: No - Does this need documentation: No
diff --git a/regression-test/data/nereids_rules_p0/column_pruning/left_join_not_null_column.out b/regression-test/data/nereids_rules_p0/column_pruning/left_join_not_null_column.out new file mode 100644 index 0000000..8a98c58 --- /dev/null +++ b/regression-test/data/nereids_rules_p0/column_pruning/left_join_not_null_column.out
@@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !left_join_not_null_column -- +3 6 60 600.00 1 +
diff --git a/regression-test/suites/nereids_rules_p0/column_pruning/left_join_not_null_column.groovy b/regression-test/suites/nereids_rules_p0/column_pruning/left_join_not_null_column.groovy new file mode 100644 index 0000000..e7e9aa1 --- /dev/null +++ b/regression-test/suites/nereids_rules_p0/column_pruning/left_join_not_null_column.groovy
@@ -0,0 +1,71 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("left_join_not_null_column") { + sql "set enable_prune_nested_column = true" + + sql "drop table if exists left_join_not_null_dim" + sql "drop table if exists left_join_not_null_fact" + + sql """ + create table left_join_not_null_dim ( + id int not null, + segment varchar(32) not null + ) + unique key(id) + distributed by hash(id) buckets 1 + properties ( + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" + ) + """ + + sql """ + create table left_join_not_null_fact ( + fact_id int not null, + dim_id int not null, + quantity int not null, + amount decimal(10, 2) not null + ) + unique key(fact_id) + distributed by hash(fact_id) buckets 1 + properties ( + "replication_num" = "1", + "enable_unique_key_merge_on_write" = "true" + ) + """ + + sql "insert into left_join_not_null_dim values (1, 'segment-a'), (2, 'segment-b')" + sql "insert into left_join_not_null_fact values (1, 1, 10, 100.00), (2, 2, 20, 200.00), (3, 3, 30, 300.00)" + + explain { + sql """ + select count(*), sum(f.fact_id), sum(f.quantity), sum(f.amount), + sum(case when d.segment is null then 1 else 0 end) + from left_join_not_null_fact f + left join left_join_not_null_dim d on f.dim_id = d.id + """ + notContains "segment.NULL" + } + + qt_left_join_not_null_column """ + select count(*), sum(f.fact_id), sum(f.quantity), sum(f.amount), + sum(case when d.segment is null then 1 else 0 end) + from left_join_not_null_fact f + left join left_join_not_null_dim d on f.dim_id = d.id + """ +}