From c3a1c0761c7aa15179dc8fffd5995b7543abc75c Mon Sep 17 00:00:00 2001 From: Andrew Lamb Date: Tue, 16 Jul 2024 12:14:19 -0400 Subject: [PATCH] Test + workaround for SanityCheck plan --- .../src/physical_optimizer/sanity_checker.rs | 10 +++++ datafusion/sqllogictest/test_files/union.slt | 37 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/datafusion/core/src/physical_optimizer/sanity_checker.rs b/datafusion/core/src/physical_optimizer/sanity_checker.rs index 6e37c3f40ffa..d3d3eb307139 100644 --- a/datafusion/core/src/physical_optimizer/sanity_checker.rs +++ b/datafusion/core/src/physical_optimizer/sanity_checker.rs @@ -34,6 +34,8 @@ use datafusion_physical_plan::joins::SymmetricHashJoinExec; use datafusion_physical_plan::{get_plan_string, ExecutionPlanProperties}; use datafusion_physical_optimizer::PhysicalOptimizerRule; +use datafusion_physical_plan::sorts::sort::SortExec; +use datafusion_physical_plan::union::UnionExec; use itertools::izip; /// The SanityCheckPlan rule rejects the following query plans: @@ -125,6 +127,14 @@ pub fn check_plan_sanity( plan.required_input_ordering().iter(), plan.required_input_distribution().iter() ) { + // TEMP HACK WORKAROUND https://github.com/apache/datafusion/issues/11492 + if child.as_any().downcast_ref::().is_some() { + continue; + } + if child.as_any().downcast_ref::().is_some() { + continue; + } + let child_eq_props = child.equivalence_properties(); if let Some(child_sort_req) = child_sort_req { if !child_eq_props.ordering_satisfy_requirement(child_sort_req) { diff --git a/datafusion/sqllogictest/test_files/union.slt b/datafusion/sqllogictest/test_files/union.slt index e1fd5eb726f1..88fad85e871d 100644 --- a/datafusion/sqllogictest/test_files/union.slt +++ b/datafusion/sqllogictest/test_files/union.slt @@ -524,6 +524,9 @@ physical_plan # Clean up after the test ######## +statement ok +drop table t + statement ok drop table t1; @@ -747,3 +750,37 @@ SELECT NULL WHERE FALSE; ---- 0.5 1 + +### +# Test for https://github.com/apache/datafusion/issues/11492 +### + +# Input data is +# a,b,c +# 1,2,3 + +statement ok +CREATE EXTERNAL TABLE t ( + a INT, + b INT, + c INT +) +STORED AS CSV +LOCATION '../core/tests/data/example.csv' +WITH ORDER (a ASC) +OPTIONS ('format.has_header' 'true'); + +query T +SELECT (SELECT a from t ORDER BY a) UNION ALL (SELECT 'bar' as a from t) ORDER BY a; +---- +1 +bar + +query I +SELECT (SELECT a from t ORDER BY a) UNION ALL (SELECT NULL as a from t) ORDER BY a; +---- +1 +NULL + +statement ok +drop table t