This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 9ae370c580 Port tests in explain.rs to sqllogictests (#6343)
9ae370c580 is described below

commit 9ae370c5800a0120eb50401f4cb762b986b60ac6
Author: yi wang <[email protected]>
AuthorDate: Fri May 12 22:49:09 2023 +0800

    Port tests in explain.rs to sqllogictests (#6343)
---
 datafusion/core/tests/sql/explain.rs               |  62 -------------
 datafusion/core/tests/sql/mod.rs                   |   1 -
 .../tests/sqllogictests/test_files/explain.slt     | 101 +++++++++++++++++++++
 3 files changed, 101 insertions(+), 63 deletions(-)

diff --git a/datafusion/core/tests/sql/explain.rs 
b/datafusion/core/tests/sql/explain.rs
deleted file mode 100644
index 041c557f45..0000000000
--- a/datafusion/core/tests/sql/explain.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-use arrow::datatypes::{DataType, Field, Schema};
-use datafusion::prelude::SessionContext;
-use datafusion::test_util::scan_empty;
-use datafusion_expr::{LogicalPlan, PlanType};
-
-#[test]
-fn optimize_explain() {
-    let schema = Schema::new(vec![Field::new("id", DataType::Int32, false)]);
-
-    let plan = scan_empty(Some("employee"), &schema, None)
-        .unwrap()
-        .explain(true, false)
-        .unwrap()
-        .build()
-        .unwrap();
-
-    if let LogicalPlan::Explain(e) = &plan {
-        assert_eq!(e.stringified_plans.len(), 1);
-    } else {
-        panic!("plan was not an explain: {plan:?}");
-    }
-
-    let ctx = SessionContext::new();
-    let state = ctx.state();
-
-    // now optimize the plan and expect to see more plans
-    let optimized_plan = state.optimize(&plan).unwrap();
-    if let LogicalPlan::Explain(e) = &optimized_plan {
-        // should have more than one plan
-        assert!(
-            e.stringified_plans.len() > 1,
-            "plans: {:#?}",
-            e.stringified_plans
-        );
-        // should have at least one optimized plan
-        let opt = e
-            .stringified_plans
-            .iter()
-            .any(|p| matches!(p.plan_type, PlanType::OptimizedLogicalPlan { .. 
}));
-
-        assert!(opt, "plans: {:#?}", e.stringified_plans);
-    } else {
-        panic!("plan was not an explain: {plan:?}");
-    }
-}
diff --git a/datafusion/core/tests/sql/mod.rs b/datafusion/core/tests/sql/mod.rs
index 8dcae60570..be7b66adb5 100644
--- a/datafusion/core/tests/sql/mod.rs
+++ b/datafusion/core/tests/sql/mod.rs
@@ -97,7 +97,6 @@ pub mod select;
 pub mod timestamp;
 pub mod udf;
 
-pub mod explain;
 pub mod information_schema;
 pub mod parquet_schema;
 pub mod partitioned_csv;
diff --git a/datafusion/core/tests/sqllogictests/test_files/explain.slt 
b/datafusion/core/tests/sqllogictests/test_files/explain.slt
index 0fdc9bf61a..65b72d0c9a 100644
--- a/datafusion/core/tests/sqllogictests/test_files/explain.slt
+++ b/datafusion/core/tests/sqllogictests/test_files/explain.slt
@@ -112,3 +112,104 @@ EXPLAIN explain select 1
 
 statement ok
 set datafusion.explain.physical_plan_only = false
+
+##########
+# EXPLAIN VERBOSE will get pass prefixed with "logical_plan after"
+##########
+
+statement ok
+CREATE EXTERNAL TABLE simple_explain_test (
+  a INT,
+  b INT,
+  c INT
+)
+STORED AS CSV
+WITH HEADER ROW
+LOCATION './tests/data/example.csv'
+
+query TT
+EXPLAIN SELECT a, b, c FROM simple_explain_test
+----
+logical_plan TableScan: simple_explain_test projection=[a, b, c]
+physical_plan CsvExec: file_groups={1 group: 
[[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, 
c], has_header=true
+
+# test EXPLAIN VERBOSE
+query TT
+EXPLAIN VERBOSE SELECT a, b, c FROM simple_explain_test
+----
+initial_logical_plan
+Projection: simple_explain_test.a, simple_explain_test.b, simple_explain_test.c
+  TableScan: simple_explain_test
+logical_plan after inline_table_scan SAME TEXT AS ABOVE
+logical_plan after type_coercion SAME TEXT AS ABOVE
+logical_plan after count_wildcard_rule SAME TEXT AS ABOVE
+analyzed_logical_plan SAME TEXT AS ABOVE
+logical_plan after simplify_expressions SAME TEXT AS ABOVE
+logical_plan after unwrap_cast_in_comparison SAME TEXT AS ABOVE
+logical_plan after replace_distinct_aggregate SAME TEXT AS ABOVE
+logical_plan after decorrelate_where_exists SAME TEXT AS ABOVE
+logical_plan after decorrelate_where_in SAME TEXT AS ABOVE
+logical_plan after scalar_subquery_to_join SAME TEXT AS ABOVE
+logical_plan after extract_equijoin_predicate SAME TEXT AS ABOVE
+logical_plan after simplify_expressions SAME TEXT AS ABOVE
+logical_plan after merge_projection SAME TEXT AS ABOVE
+logical_plan after rewrite_disjunctive_predicate SAME TEXT AS ABOVE
+logical_plan after eliminate_duplicated_expr SAME TEXT AS ABOVE
+logical_plan after eliminate_filter SAME TEXT AS ABOVE
+logical_plan after eliminate_cross_join SAME TEXT AS ABOVE
+logical_plan after common_sub_expression_eliminate SAME TEXT AS ABOVE
+logical_plan after eliminate_limit SAME TEXT AS ABOVE
+logical_plan after propagate_empty_relation SAME TEXT AS ABOVE
+logical_plan after filter_null_join_keys SAME TEXT AS ABOVE
+logical_plan after eliminate_outer_join SAME TEXT AS ABOVE
+logical_plan after push_down_limit SAME TEXT AS ABOVE
+logical_plan after push_down_filter SAME TEXT AS ABOVE
+logical_plan after single_distinct_aggregation_to_group_by SAME TEXT AS ABOVE
+logical_plan after simplify_expressions SAME TEXT AS ABOVE
+logical_plan after unwrap_cast_in_comparison SAME TEXT AS ABOVE
+logical_plan after common_sub_expression_eliminate SAME TEXT AS ABOVE
+logical_plan after push_down_projection
+Projection: simple_explain_test.a, simple_explain_test.b, simple_explain_test.c
+  TableScan: simple_explain_test projection=[a, b, c]
+logical_plan after eliminate_projection TableScan: simple_explain_test 
projection=[a, b, c]
+logical_plan after push_down_limit SAME TEXT AS ABOVE
+logical_plan after simplify_expressions SAME TEXT AS ABOVE
+logical_plan after unwrap_cast_in_comparison SAME TEXT AS ABOVE
+logical_plan after replace_distinct_aggregate SAME TEXT AS ABOVE
+logical_plan after decorrelate_where_exists SAME TEXT AS ABOVE
+logical_plan after decorrelate_where_in SAME TEXT AS ABOVE
+logical_plan after scalar_subquery_to_join SAME TEXT AS ABOVE
+logical_plan after extract_equijoin_predicate SAME TEXT AS ABOVE
+logical_plan after simplify_expressions SAME TEXT AS ABOVE
+logical_plan after merge_projection SAME TEXT AS ABOVE
+logical_plan after rewrite_disjunctive_predicate SAME TEXT AS ABOVE
+logical_plan after eliminate_duplicated_expr SAME TEXT AS ABOVE
+logical_plan after eliminate_filter SAME TEXT AS ABOVE
+logical_plan after eliminate_cross_join SAME TEXT AS ABOVE
+logical_plan after common_sub_expression_eliminate SAME TEXT AS ABOVE
+logical_plan after eliminate_limit SAME TEXT AS ABOVE
+logical_plan after propagate_empty_relation SAME TEXT AS ABOVE
+logical_plan after filter_null_join_keys SAME TEXT AS ABOVE
+logical_plan after eliminate_outer_join SAME TEXT AS ABOVE
+logical_plan after push_down_limit SAME TEXT AS ABOVE
+logical_plan after push_down_filter SAME TEXT AS ABOVE
+logical_plan after single_distinct_aggregation_to_group_by SAME TEXT AS ABOVE
+logical_plan after simplify_expressions SAME TEXT AS ABOVE
+logical_plan after unwrap_cast_in_comparison SAME TEXT AS ABOVE
+logical_plan after common_sub_expression_eliminate SAME TEXT AS ABOVE
+logical_plan after push_down_projection SAME TEXT AS ABOVE
+logical_plan after eliminate_projection SAME TEXT AS ABOVE
+logical_plan after push_down_limit SAME TEXT AS ABOVE
+logical_plan TableScan: simple_explain_test projection=[a, b, c]
+initial_physical_plan CsvExec: file_groups={1 group: 
[[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, 
c], has_header=true
+physical_plan after aggregate_statistics SAME TEXT AS ABOVE
+physical_plan after join_selection SAME TEXT AS ABOVE
+physical_plan after PipelineFixer SAME TEXT AS ABOVE
+physical_plan after repartition SAME TEXT AS ABOVE
+physical_plan after global_sort_selection SAME TEXT AS ABOVE
+physical_plan after EnforceDistribution SAME TEXT AS ABOVE
+physical_plan after EnforceSorting SAME TEXT AS ABOVE
+physical_plan after CombinePartialFinalAggregate SAME TEXT AS ABOVE
+physical_plan after coalesce_batches SAME TEXT AS ABOVE
+physical_plan after PipelineChecker SAME TEXT AS ABOVE
+physical_plan CsvExec: file_groups={1 group: 
[[WORKSPACE_ROOT/datafusion/core/tests/data/example.csv]]}, projection=[a, b, 
c], has_header=true

Reply via email to