Skip to content

Commit

Permalink
revert apache#3662
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrove committed Oct 3, 2022
1 parent 0eee723 commit 49ba27c
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 206 deletions.
20 changes: 19 additions & 1 deletion datafusion/core/tests/sql/explain_analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,8 @@ async fn test_physical_plan_display_indent_multi_children() {
#[tokio::test]
#[cfg_attr(tarpaulin, ignore)]
async fn csv_explain() {
// TODO: https://github.com/apache/arrow-datafusion/issues/3622 refactor the `PreCastLitInComparisonExpressions`

// This test uses the execute function that create full plan cycle: logical, optimized logical, and physical,
// then execute the physical plan and return the final explain results
let ctx = SessionContext::new();
Expand All @@ -777,6 +779,23 @@ async fn csv_explain() {

// Note can't use `assert_batches_eq` as the plan needs to be
// normalized for filenames and number of cores
let expected = vec![
vec![
"logical_plan",
"Projection: #aggregate_test_100.c1\
\n Filter: CAST(#aggregate_test_100.c2 AS Int32) > Int32(10)\
\n TableScan: aggregate_test_100 projection=[c1, c2], partial_filters=[CAST(#aggregate_test_100.c2 AS Int32) > Int32(10)]"
],
vec!["physical_plan",
"ProjectionExec: expr=[c1@0 as c1]\
\n CoalesceBatchesExec: target_batch_size=4096\
\n FilterExec: CAST(c2@1 AS Int32) > 10\
\n RepartitionExec: partitioning=RoundRobinBatch(NUM_CORES)\
\n CsvExec: files=[ARROW_TEST_DATA/csv/aggregate_test_100.csv], has_header=true, limit=None, projection=[c1, c2]\
\n"
]];
assert_eq!(expected, actual);

let expected = vec![
vec![
"logical_plan",
Expand All @@ -792,7 +811,6 @@ async fn csv_explain() {
\n CsvExec: files=[ARROW_TEST_DATA/csv/aggregate_test_100.csv], has_header=true, limit=None, projection=[c1, c2]\
\n"
]];
assert_eq!(expected, actual);

let sql = "explain SELECT c1 FROM aggregate_test_100 where c2 > 10";
let actual = execute(&ctx, sql).await;
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ pub mod subquery_filter_to_join;
pub mod type_coercion;
pub mod utils;

pub mod pre_cast_lit_in_comparison;
pub mod rewrite_disjunctive_predicate;
#[cfg(test)]
pub mod test;
pub mod unwrap_cast_in_comparison;

pub use optimizer::{OptimizerConfig, OptimizerRule};
4 changes: 2 additions & 2 deletions datafusion/optimizer/src/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ use crate::simplify_expressions::SimplifyExpressions;
use crate::single_distinct_to_groupby::SingleDistinctToGroupBy;
use crate::subquery_filter_to_join::SubqueryFilterToJoin;
use crate::type_coercion::TypeCoercion;
use crate::unwrap_cast_in_comparison::UnwrapCastInComparison;
use chrono::{DateTime, Utc};
use datafusion_common::{DataFusionError, Result};
use datafusion_expr::logical_plan::LogicalPlan;
use log::{debug, trace, warn};
use std::sync::Arc;
use crate::pre_cast_lit_in_comparison::PreCastLitInComparisonExpressions;

/// `OptimizerRule` transforms one ['LogicalPlan'] into another which
/// computes the same results, but in a potentially more efficient
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Optimizer {
/// Create a new optimizer using the recommended list of rules
pub fn new(config: &OptimizerConfig) -> Self {
let mut rules: Vec<Arc<dyn OptimizerRule + Sync + Send>> = vec![
Arc::new(UnwrapCastInComparison::new()),
Arc::new(PreCastLitInComparisonExpressions::new()),
Arc::new(TypeCoercion::new()),
Arc::new(SimplifyExpressions::new()),
Arc::new(DecorrelateWhereExists::new()),
Expand Down
Loading

0 comments on commit 49ba27c

Please sign in to comment.