mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-14 17:23:09 +00:00
feat: dist plan optimize part 2 (#2543)
* allow udf and scalar fn Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * put CountWildcardRule before dist planner Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * bump datafusion to fix first_value/last_value Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * update sqlness result Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * use retain instead Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
@@ -140,7 +140,9 @@ impl Categorizer {
|
||||
| Expr::Negative(_)
|
||||
| Expr::Between(_)
|
||||
| Expr::Sort(_)
|
||||
| Expr::Exists(_) => Commutativity::Commutative,
|
||||
| Expr::Exists(_)
|
||||
| Expr::ScalarFunction(_)
|
||||
| Expr::ScalarUDF(_) => Commutativity::Commutative,
|
||||
|
||||
Expr::Like(_)
|
||||
| Expr::SimilarTo(_)
|
||||
@@ -150,8 +152,6 @@ impl Categorizer {
|
||||
| Expr::Case(_)
|
||||
| Expr::Cast(_)
|
||||
| Expr::TryCast(_)
|
||||
| Expr::ScalarFunction(_)
|
||||
| Expr::ScalarUDF(_)
|
||||
| Expr::AggregateFunction(_)
|
||||
| Expr::WindowFunction(_)
|
||||
| Expr::AggregateUDF(_)
|
||||
|
||||
@@ -34,7 +34,8 @@ use datafusion::physical_optimizer::PhysicalOptimizerRule;
|
||||
use datafusion::physical_plan::ExecutionPlan;
|
||||
use datafusion::physical_planner::{DefaultPhysicalPlanner, ExtensionPlanner, PhysicalPlanner};
|
||||
use datafusion_expr::LogicalPlan as DfLogicalPlan;
|
||||
use datafusion_optimizer::analyzer::Analyzer;
|
||||
use datafusion_optimizer::analyzer::count_wildcard_rule::CountWildcardRule;
|
||||
use datafusion_optimizer::analyzer::{Analyzer, AnalyzerRule};
|
||||
use datafusion_optimizer::optimizer::Optimizer;
|
||||
use promql::extension_plan::PromExtensionPlanner;
|
||||
use substrait::extension_serializer::ExtensionSerializer;
|
||||
@@ -88,6 +89,8 @@ impl QueryEngineState {
|
||||
}
|
||||
analyzer.rules.insert(0, Arc::new(TypeConversionRule));
|
||||
analyzer.rules.insert(0, Arc::new(StringNormalizationRule));
|
||||
Self::remove_analyzer_rule(&mut analyzer.rules, CountWildcardRule {}.name());
|
||||
analyzer.rules.insert(0, Arc::new(CountWildcardRule {}));
|
||||
let mut optimizer = Optimizer::new();
|
||||
optimizer.rules.push(Arc::new(OrderHintRule));
|
||||
|
||||
@@ -132,20 +135,15 @@ impl QueryEngineState {
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_analyzer_rule(rules: &mut Vec<Arc<dyn AnalyzerRule + Send + Sync>>, name: &str) {
|
||||
rules.retain(|rule| rule.name() != name);
|
||||
}
|
||||
|
||||
fn remove_physical_optimize_rule(
|
||||
rules: &mut Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>,
|
||||
name: &str,
|
||||
) {
|
||||
let mut index_to_move = None;
|
||||
for (i, rule) in rules.iter().enumerate() {
|
||||
if rule.name() == name {
|
||||
index_to_move = Some(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if let Some(index) = index_to_move {
|
||||
let _ = rules.remove(index);
|
||||
}
|
||||
rules.retain(|rule| rule.name() != name);
|
||||
}
|
||||
|
||||
/// Register a udf function
|
||||
|
||||
Reference in New Issue
Block a user