@@ -538,9 +538,6 @@ physical_plan
538538# Clean up after the test
539539########
540540
541- statement ok
542- drop table t
543-
544541statement ok
545542drop table t1;
546543
@@ -781,36 +778,76 @@ select make_array(make_array(1)) x UNION ALL SELECT make_array(arrow_cast(make_a
781778[[-1]]
782779[[1]]
783780
784- ###
785- # Test for https://github.com/apache/datafusion/issues/11492
786- ###
787-
788- # Input data is
789- # a,b,c
790- # 1,2,3
791-
792781statement ok
793- CREATE EXTERNAL TABLE t (
794- a INT,
795- b INT,
796- c INT
782+ CREATE EXTERNAL TABLE aggregate_test_100 (
783+ c1 VARCHAR NOT NULL,
784+ c2 TINYINT NOT NULL,
785+ c3 SMALLINT NOT NULL,
786+ c4 SMALLINT,
787+ c5 INT,
788+ c6 BIGINT NOT NULL,
789+ c7 SMALLINT NOT NULL,
790+ c8 INT NOT NULL,
791+ c9 BIGINT UNSIGNED NOT NULL,
792+ c10 VARCHAR NOT NULL,
793+ c11 FLOAT NOT NULL,
794+ c12 DOUBLE NOT NULL,
795+ c13 VARCHAR NOT NULL
797796)
798797STORED AS CSV
799- LOCATION '../core/tests/data/example.csv'
800- WITH ORDER (a ASC)
798+ LOCATION '../../testing/data/csv/aggregate_test_100.csv'
801799OPTIONS ('format.has_header' 'true');
802800
803- query T
804- SELECT (SELECT a from t ORDER BY a) UNION ALL (SELECT 'bar' as a from t) ORDER BY a;
805- ----
806- 1
807- bar
801+ statement ok
802+ set datafusion.execution.batch_size = 2;
808803
809- query I
810- SELECT (SELECT a from t ORDER BY a) UNION ALL (SELECT NULL as a from t) ORDER BY a;
804+ # Constant value tracking across union
805+ query TT
806+ explain
807+ SELECT * FROM(
808+ (
809+ SELECT * FROM aggregate_test_100 WHERE c1='a'
810+ )
811+ UNION ALL
812+ (
813+ SELECT * FROM aggregate_test_100 WHERE c1='a'
814+ ))
815+ ORDER BY c1
811816----
812- 1
813- NULL
817+ logical_plan
818+ 01)Sort: aggregate_test_100.c1 ASC NULLS LAST
819+ 02)--Union
820+ 03)----Filter: aggregate_test_100.c1 = Utf8("a")
821+ 04)------TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], partial_filters=[aggregate_test_100.c1 = Utf8("a")]
822+ 05)----Filter: aggregate_test_100.c1 = Utf8("a")
823+ 06)------TableScan: aggregate_test_100 projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], partial_filters=[aggregate_test_100.c1 = Utf8("a")]
824+ physical_plan
825+ 01)CoalescePartitionsExec
826+ 02)--UnionExec
827+ 03)----CoalesceBatchesExec: target_batch_size=2
828+ 04)------FilterExec: c1@0 = a
829+ 05)--------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
830+ 06)----------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], has_header=true
831+ 07)----CoalesceBatchesExec: target_batch_size=2
832+ 08)------FilterExec: c1@0 = a
833+ 09)--------RepartitionExec: partitioning=RoundRobinBatch(4), input_partitions=1
834+ 10)----------CsvExec: file_groups={1 group: [[WORKSPACE_ROOT/testing/data/csv/aggregate_test_100.csv]]}, projection=[c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13], has_header=true
814835
836+ # Clean up after the test
815837statement ok
816- drop table t
838+ drop table aggregate_test_100;
839+
840+ # test for https://github.com/apache/datafusion/issues/14352
841+ query TB rowsort
842+ SELECT
843+ a,
844+ a IS NOT NULL
845+ FROM (
846+ -- second column, even though it's not selected, was necessary to reproduce the bug linked above
847+ SELECT 'foo' AS a, 3 AS b
848+ UNION ALL
849+ SELECT NULL AS a, 4 AS b
850+ )
851+ ----
852+ NULL false
853+ foo true
0 commit comments