Changeset: 39f3aa987a42 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/39f3aa987a42
Added Files:
        sql/test/BugTracker-2026/Tests/8015-join-subquery-NULL-bug.test
Modified Files:
        sql/test/BugTracker-2026/Tests/All
Branch: Dec2025
Log Message:

Add test for issue #8015


diffs (84 lines):

diff --git a/sql/test/BugTracker-2026/Tests/8015-join-subquery-NULL-bug.test 
b/sql/test/BugTracker-2026/Tests/8015-join-subquery-NULL-bug.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2026/Tests/8015-join-subquery-NULL-bug.test
@@ -0,0 +1,71 @@
+statement ok
+CREATE TABLE t8015 (x INT)
+
+statement ok rowcount 2
+INSERT INTO t8015 VALUES (1), (2)
+
+query I nosort
+SELECT SUM(x) AS a
+  FROM t8015
+ GROUP BY x
+HAVING SUM(x) < 0
+----
+
+-- The grouped input is empty, so SUM(a) is NULL.
+query I nosort
+SELECT SUM(a) AS s
+  FROM (
+    SELECT SUM(x) AS a
+      FROM t8015
+     GROUP BY x
+    HAVING SUM(x) < 0
+       ) AS grouped_rows
+----
+NULL
+
+-- The grouped input is empty, so SUM(a) is NULL and the join must match no 
rows.
+query I nosort
+SELECT COUNT(*) AS original_count
+FROM t8015 AS o
+JOIN (
+    SELECT SUM(a) AS s
+    FROM (
+        SELECT SUM(x) AS a
+          FROM t8015
+         GROUP BY x
+        HAVING SUM(x) < 0
+    ) AS grouped_rows
+) AS q ON q.s IS NOT NULL
+----
+0
+
+statement ok
+CREATE TEMPORARY TABLE t8015_tmp AS
+SELECT SUM(x) AS a
+  FROM t8015
+ GROUP BY x
+HAVING SUM(x) < 0
+ON COMMIT PRESERVE ROWS
+
+query I nosort
+SELECT COUNT(*) AS cut_count
+FROM t8015_tmp
+----
+0
+
+query I nosort
+SELECT COUNT(*) AS residual_count
+FROM t8015 AS o
+JOIN (
+    SELECT SUM(a) AS s
+    FROM t8015_tmp
+) AS q ON q.s IS NOT NULL
+----
+0
+
+statement ok
+DROP TABLE t8015_tmp
+
+statement ok
+DROP TABLE t8015
+
diff --git a/sql/test/BugTracker-2026/Tests/All 
b/sql/test/BugTracker-2026/Tests/All
--- a/sql/test/BugTracker-2026/Tests/All
+++ b/sql/test/BugTracker-2026/Tests/All
@@ -193,3 +193,4 @@ KNOWNFAIL?8009-numeric-range-nulls-last-
 KNOWNFAIL?8010-first_value-last_value-partition-range-bug
 KNOWNFAIL?8013-triple-same-predicate-bug
 KNOWNFAIL?8014-rel_bin-exp_bin-assert-failure
+KNOWNFAIL?8015-join-subquery-NULL-bug
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to