From d343662b403703f3015a7fc8a062a09bd12b8a37 Mon Sep 17 00:00:00 2001 From: Rohan Krishnaswamy Date: Sun, 9 Feb 2025 14:41:51 -0800 Subject: [PATCH] more tests --- .../sqllogictest/test_files/union_by_name.slt | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/datafusion/sqllogictest/test_files/union_by_name.slt b/datafusion/sqllogictest/test_files/union_by_name.slt index 8850681f4291..ae66e3b40440 100644 --- a/datafusion/sqllogictest/test_files/union_by_name.slt +++ b/datafusion/sqllogictest/test_files/union_by_name.slt @@ -35,12 +35,32 @@ SELECT t1.x FROM t1 UNION BY NAME SELECT x FROM t1 ORDER BY t1.x; 1 3 +query I +SELECT t1.x FROM t1 UNION ALL BY NAME SELECT x FROM t1 ORDER BY t1.x; +---- +1 +1 +3 +3 +3 +3 + query I SELECT x FROM t1 UNION BY NAME SELECT x FROM t1 ORDER BY t1.x; ---- 1 3 +query I +SELECT x FROM t1 UNION ALL BY NAME SELECT x FROM t1 ORDER BY t1.x; +---- +1 +1 +3 +3 +3 +3 + query II (SELECT x FROM t1 UNION ALL SELECT x FROM t1) UNION BY NAME SELECT 5 ORDER BY x; ---- @@ -48,6 +68,16 @@ NULL 1 NULL 3 5 NULL +# TODO: This should pass, but the sanity checker isn't allowing it. +# Commenting out the ordering check in the sanity checker produces the correct result. +query error +(SELECT x FROM t1 UNION ALL SELECT x FROM t1) UNION ALL BY NAME SELECT 5 ORDER BY x; +---- +DataFusion error: SanityCheckPlan +caused by +Error during planning: Plan: ["SortPreservingMergeExec: [x@1 ASC NULLS LAST]", " UnionExec", " SortExec: expr=[x@1 ASC NULLS LAST], preserve_partitioning=[true]", " ProjectionExec: expr=[NULL as Int64(5), x@0 as x]", " UnionExec", " MemoryExec: partitions=1, partition_sizes=[1]", " MemoryExec: partitions=1, partition_sizes=[1]", " ProjectionExec: expr=[5 as Int64(5), NULL as x]", " PlaceholderRowExec"] does not satisfy order requirements: [x@1 ASC NULLS LAST]. Child-0 order: [] + + query II (SELECT x FROM t1 UNION ALL SELECT y FROM t1) UNION BY NAME SELECT 5 ORDER BY x; ---- @@ -55,6 +85,16 @@ NULL 1 NULL 3 5 NULL +# TODO: This should pass, but the sanity checker isn't allowing it. +# Commenting out the ordering check in the sanity checker produces the correct result. +query error +(SELECT x FROM t1 UNION ALL SELECT y FROM t1) UNION ALL BY NAME SELECT 5 ORDER BY x; +---- +DataFusion error: SanityCheckPlan +caused by +Error during planning: Plan: ["SortPreservingMergeExec: [x@1 ASC NULLS LAST]", " UnionExec", " SortExec: expr=[x@1 ASC NULLS LAST], preserve_partitioning=[true]", " ProjectionExec: expr=[NULL as Int64(5), x@0 as x]", " UnionExec", " MemoryExec: partitions=1, partition_sizes=[1]", " ProjectionExec: expr=[y@0 as x]", " MemoryExec: partitions=1, partition_sizes=[1]", " ProjectionExec: expr=[5 as Int64(5), NULL as x]", " PlaceholderRowExec"] does not satisfy order requirements: [x@1 ASC NULLS LAST]. Child-0 order: [] + + # Ambiguous name