@@ -39,7 +39,6 @@ use datafusion::optimizer::push_down_filter::PushDownFilter;
39
39
use datafusion:: optimizer:: replace_distinct_aggregate:: ReplaceDistinctWithAggregate ;
40
40
use datafusion:: optimizer:: rewrite_disjunctive_predicate:: RewriteDisjunctivePredicate ;
41
41
use datafusion:: optimizer:: scalar_subquery_to_join:: ScalarSubqueryToJoin ;
42
- use datafusion:: optimizer:: simplify_expressions:: SimplifyExpressions ;
43
42
use datafusion:: optimizer:: single_distinct_to_groupby:: SingleDistinctToGroupBy ;
44
43
use datafusion:: optimizer:: unwrap_cast_in_comparison:: UnwrapCastInComparison ;
45
44
use datafusion:: optimizer:: OptimizerRule ;
@@ -77,10 +76,13 @@ pub async fn create_ctx_with_mdl(
77
76
Arc :: clone( & reset_default_catalog_schema) ,
78
77
) ) ,
79
78
Arc :: new( ModelAnalyzeRule :: new(
79
+ Arc :: clone( & analyzed_mdl) ,
80
+ Arc :: clone( & reset_default_catalog_schema) ,
81
+ ) ) ,
82
+ Arc :: new( ModelGenerationRule :: new(
80
83
Arc :: clone( & analyzed_mdl) ,
81
84
reset_default_catalog_schema,
82
85
) ) ,
83
- Arc :: new( ModelGenerationRule :: new( Arc :: clone( & analyzed_mdl) ) ) ,
84
86
Arc :: new( InlineTableScan :: new( ) ) ,
85
87
// Every rule that will generate [Expr::Wildcard] should be placed in front of [ExpandWildcardRule].
86
88
Arc :: new( ExpandWildcardRule :: new( ) ) ,
@@ -106,17 +108,16 @@ pub async fn create_ctx_with_mdl(
106
108
fn optimize_rule_for_unparsing ( ) -> Vec < Arc < dyn OptimizerRule + Send + Sync > > {
107
109
vec ! [
108
110
Arc :: new( EliminateNestedUnion :: new( ) ) ,
109
- Arc :: new( SimplifyExpressions :: new( ) ) ,
111
+ // Disable SimplifyExpressions to avoid apply some function locally
112
+ // Arc::new(SimplifyExpressions::new()),
110
113
Arc :: new( UnwrapCastInComparison :: new( ) ) ,
111
114
Arc :: new( ReplaceDistinctWithAggregate :: new( ) ) ,
112
115
Arc :: new( EliminateJoin :: new( ) ) ,
113
116
Arc :: new( DecorrelatePredicateSubquery :: new( ) ) ,
114
117
Arc :: new( ScalarSubqueryToJoin :: new( ) ) ,
115
118
Arc :: new( ExtractEquijoinPredicate :: new( ) ) ,
116
- // simplify expressions does not simplify expressions in subqueries, so we
117
- // run it again after running the optimizations that potentially converted
118
- // subqueries to joins
119
- Arc :: new( SimplifyExpressions :: new( ) ) ,
119
+ // Disable SimplifyExpressions to avoid apply some function locally
120
+ // Arc::new(SimplifyExpressions::new()),
120
121
Arc :: new( RewriteDisjunctivePredicate :: new( ) ) ,
121
122
Arc :: new( EliminateDuplicatedExpr :: new( ) ) ,
122
123
Arc :: new( EliminateFilter :: new( ) ) ,
@@ -133,9 +134,8 @@ fn optimize_rule_for_unparsing() -> Vec<Arc<dyn OptimizerRule + Send + Sync>> {
133
134
// Arc::new(PushDownLimit::new()),
134
135
Arc :: new( PushDownFilter :: new( ) ) ,
135
136
Arc :: new( SingleDistinctToGroupBy :: new( ) ) ,
136
- // The previous optimizations added expressions and projections,
137
- // that might benefit from the following rules
138
- Arc :: new( SimplifyExpressions :: new( ) ) ,
137
+ // Disable SimplifyExpressions to avoid apply some function locally
138
+ // Arc::new(SimplifyExpressions::new()),
139
139
Arc :: new( UnwrapCastInComparison :: new( ) ) ,
140
140
Arc :: new( CommonSubexprEliminate :: new( ) ) ,
141
141
Arc :: new( EliminateGroupByConstant :: new( ) ) ,
0 commit comments