Skip to content

Commit 9861a64

Browse files
alambwiedld
authored andcommitted
Test + workaround for SanityCheck plan
1 parent 63efaee commit 9861a64

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

datafusion/core/src/physical_optimizer/sanity_checker.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ use datafusion_physical_plan::joins::SymmetricHashJoinExec;
3434
use datafusion_physical_plan::{get_plan_string, ExecutionPlanProperties};
3535

3636
use datafusion_physical_optimizer::PhysicalOptimizerRule;
37+
use datafusion_physical_plan::sorts::sort::SortExec;
38+
use datafusion_physical_plan::union::UnionExec;
3739
use itertools::izip;
3840

3941
/// The SanityCheckPlan rule rejects the following query plans:
@@ -125,6 +127,14 @@ pub fn check_plan_sanity(
125127
plan.required_input_ordering().iter(),
126128
plan.required_input_distribution().iter()
127129
) {
130+
// TEMP HACK WORKAROUND https://github.com/apache/datafusion/issues/11492
131+
if child.as_any().downcast_ref::<UnionExec>().is_some() {
132+
continue;
133+
}
134+
if child.as_any().downcast_ref::<SortExec>().is_some() {
135+
continue;
136+
}
137+
128138
let child_eq_props = child.equivalence_properties();
129139
if let Some(child_sort_req) = child_sort_req {
130140
if !child_eq_props.ordering_satisfy_requirement(child_sort_req) {

datafusion/sqllogictest/test_files/union.slt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ physical_plan
464464
# Clean up after the test
465465
########
466466

467+
statement ok
468+
drop table t
469+
467470
statement ok
468471
drop table t1;
469472

@@ -647,3 +650,36 @@ DROP TABLE t1;
647650

648651
statement ok
649652
DROP TABLE t2;
653+
###
654+
# Test for https://github.com/apache/datafusion/issues/11492
655+
###
656+
657+
# Input data is
658+
# a,b,c
659+
# 1,2,3
660+
661+
statement ok
662+
CREATE EXTERNAL TABLE t (
663+
a INT,
664+
b INT,
665+
c INT
666+
)
667+
STORED AS CSV
668+
LOCATION '../core/tests/data/example.csv'
669+
WITH ORDER (a ASC)
670+
OPTIONS ('format.has_header' 'true');
671+
672+
query T
673+
SELECT (SELECT a from t ORDER BY a) UNION ALL (SELECT 'bar' as a from t) ORDER BY a;
674+
----
675+
1
676+
bar
677+
678+
query I
679+
SELECT (SELECT a from t ORDER BY a) UNION ALL (SELECT NULL as a from t) ORDER BY a;
680+
----
681+
1
682+
NULL
683+
684+
statement ok
685+
drop table t

0 commit comments

Comments
 (0)