andygrove commented on code in PR #2851:
URL: https://github.com/apache/datafusion-comet/pull/2851#discussion_r2592896180
##########
native/core/src/execution/planner.rs:
##########
@@ -242,126 +245,13 @@ impl PhysicalPlanner {
spark_expr: &Expr,
input_schema: SchemaRef,
) -> Result<Arc<dyn PhysicalExpr>, ExecutionError> {
- match spark_expr.expr_struct.as_ref().unwrap() {
- ExprStruct::Add(expr) => {
- let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?;
- self.create_binary_expr(
- expr.left.as_ref().unwrap(),
- expr.right.as_ref().unwrap(),
- expr.return_type.as_ref(),
- DataFusionOperator::Plus,
- input_schema,
- eval_mode,
- )
- }
- ExprStruct::Subtract(expr) => {
- let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?;
- self.create_binary_expr(
- expr.left.as_ref().unwrap(),
- expr.right.as_ref().unwrap(),
- expr.return_type.as_ref(),
- DataFusionOperator::Minus,
- input_schema,
- eval_mode,
- )
- }
- ExprStruct::Multiply(expr) => {
- let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?;
- self.create_binary_expr(
- expr.left.as_ref().unwrap(),
- expr.right.as_ref().unwrap(),
- expr.return_type.as_ref(),
- DataFusionOperator::Multiply,
- input_schema,
- eval_mode,
- )
- }
- ExprStruct::Divide(expr) => {
- let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?;
- self.create_binary_expr(
- expr.left.as_ref().unwrap(),
- expr.right.as_ref().unwrap(),
- expr.return_type.as_ref(),
- DataFusionOperator::Divide,
- input_schema,
- eval_mode,
- )
- }
- ExprStruct::IntegralDivide(expr) => {
- let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?;
- self.create_binary_expr_with_options(
- expr.left.as_ref().unwrap(),
- expr.right.as_ref().unwrap(),
- expr.return_type.as_ref(),
- DataFusionOperator::Divide,
- input_schema,
- BinaryExprOptions {
- is_integral_div: true,
- },
- eval_mode,
- )
- }
- ExprStruct::Remainder(expr) => {
- let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?;
- // TODO add support for EvalMode::TRY
- // https://github.com/apache/datafusion-comet/issues/2021
- let left =
- self.create_expr(expr.left.as_ref().unwrap(),
Arc::clone(&input_schema))?;
- let right =
- self.create_expr(expr.right.as_ref().unwrap(),
Arc::clone(&input_schema))?;
+ // Try to use the modular registry first - this automatically handles
any registered expression types
+ if ExpressionRegistry::global().can_handle(spark_expr) {
+ return ExpressionRegistry::global().create_expr(spark_expr,
input_schema, self);
+ }
Review Comment:
This is the main change in the planner
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]