Skip to content

Commit ec3255f

Browse files
committed
fix: revert nullability changes and update test for issue #25978
1 parent 5218379 commit ec3255f

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
##########
19+
# Regression test for https://github.com/apache/datafusion/issues/25978
20+
# A GROUP BY aggregate over a UNION ALL fails to plan when one branch
21+
# projects coalesce(<nullable boolean expression>, FALSE).
22+
# The CSE optimizer rewrites this into an AND/OR pattern whose
23+
# nullability was incorrectly reported, causing a physical vs logical
24+
# schema mismatch.
25+
##########
26+
27+
statement ok
28+
CREATE TABLE a (k VARCHAR NOT NULL, x VARCHAR) AS VALUES ('k1', 'y'), ('k2', NULL);
29+
30+
statement ok
31+
CREATE TABLE b (k VARCHAR NOT NULL) AS VALUES ('k3');
32+
33+
query TB rowsort
34+
SELECT k, bool_or(f) AS f FROM (
35+
SELECT k, coalesce(x = 'y', FALSE) AS f FROM a
36+
UNION ALL
37+
SELECT k, TRUE AS f FROM b
38+
) u GROUP BY k;
39+
----
40+
k1 true
41+
k2 false
42+
k3 true
43+
44+
statement ok
45+
DROP TABLE a;
46+
47+
statement ok
48+
DROP TABLE b;

0 commit comments

Comments
 (0)