Skip to content

Commit ec1c4ca

Browse files
committed
feat(tests): add edge cases for SQL logic tests in cte.slt
- Implemented 4 new edge cases for UNION distinct and outer null checks. - Added tests for non-first column nullability. - Included type coercion scenarios with INT and BIGINT. - Asserts nullable output schema for DESCRIBE WITH RECURSIVE.
1 parent a204864 commit ec1c4ca

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

  • datafusion/sqllogictest/test_files

datafusion/sqllogictest/test_files/cte.slt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,52 @@ SELECT * FROM t WHERE a IS NULL
235235
----
236236
NULL
237237

238+
# deduplicating recursive CTE must preserve widened nullability for outer filters.
239+
query I
240+
WITH RECURSIVE t(a) AS (
241+
SELECT 1 AS a
242+
UNION
243+
SELECT CAST(NULL AS INT) AS a FROM t WHERE a IS NOT NULL
244+
)
245+
SELECT * FROM t WHERE a IS NULL
246+
----
247+
NULL
248+
249+
# recursive output nullability must be tracked per column, not just for the
250+
# first column.
251+
query II rowsort
252+
WITH RECURSIVE t(a, b) AS (
253+
SELECT 0 AS a, 0 AS b
254+
UNION ALL
255+
SELECT b AS a, CAST(NULL AS INT) AS b FROM t WHERE a IS NOT NULL
256+
)
257+
SELECT * FROM t WHERE b IS NULL
258+
----
259+
0 NULL
260+
NULL NULL
261+
262+
# recursive output nullability must survive recursive term type coercion.
263+
query I
264+
WITH RECURSIVE t(a) AS (
265+
SELECT 1::INT AS a
266+
UNION ALL
267+
SELECT CAST(NULL AS BIGINT) AS a FROM t WHERE a IS NOT NULL
268+
)
269+
SELECT * FROM t WHERE a IS NULL
270+
----
271+
NULL
272+
273+
# DESCRIBE should expose the widened recursive output nullability.
274+
query TTT
275+
DESCRIBE WITH RECURSIVE t(a) AS (
276+
SELECT 1 AS a
277+
UNION ALL
278+
SELECT CAST(NULL AS INT) AS a FROM t WHERE a IS NOT NULL
279+
)
280+
SELECT * FROM t
281+
----
282+
a Int64 YES
283+
238284
# deduplicating recursive CTE with two variables works
239285
query II
240286
WITH RECURSIVE ranges AS (

0 commit comments

Comments
 (0)