- 
                Notifications
    
You must be signed in to change notification settings  - Fork 247
 
feat: implement_ansi_eval_mode_arithmetic #2136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 36 commits
62bfa8b
              e78bc99
              2f8701e
              bcda6c3
              f9ec308
              85acae5
              d4d125a
              0d36d60
              46790d3
              0e95fa1
              7e0603e
              88f3745
              b8f6f64
              4fce770
              2b762fc
              332b402
              6897c53
              7a0e9f8
              219648e
              82b654c
              fc2a217
              5255a75
              44d1155
              d8e30c6
              7d5b742
              31440b0
              daaac80
              0cad323
              72a639c
              f79f34d
              d08955c
              6835db4
              b70ac3b
              1eca257
              0ef832b
              182e245
              d8b8b27
              0991f13
              9603223
              d9fbd0c
              2398fd8
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -62,8 +62,9 @@ use datafusion::{ | |
| prelude::SessionContext, | ||
| }; | ||
| use datafusion_comet_spark_expr::{ | ||
| create_comet_physical_fun, create_modulo_expr, create_negate_expr, BloomFilterAgg, | ||
| BloomFilterMightContain, EvalMode, SparkHour, SparkMinute, SparkSecond, | ||
| create_comet_physical_fun, create_comet_physical_fun_with_eval_mode, create_modulo_expr, | ||
| create_negate_expr, BloomFilterAgg, BloomFilterMightContain, EvalMode, SparkHour, SparkMinute, | ||
| SparkSecond, | ||
| }; | ||
| 
     | 
||
| use crate::execution::operators::ExecutionError::GeneralError; | ||
| 
          
            
          
           | 
    @@ -241,8 +242,6 @@ impl PhysicalPlanner { | |
| ) -> Result<Arc<dyn PhysicalExpr>, ExecutionError> { | ||
| match spark_expr.expr_struct.as_ref().unwrap() { | ||
| ExprStruct::Add(expr) => { | ||
| // TODO respect ANSI eval mode | ||
| // https://github.com/apache/datafusion-comet/issues/536 | ||
| let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?; | ||
| self.create_binary_expr( | ||
| expr.left.as_ref().unwrap(), | ||
| 
        
          
        
         | 
    @@ -254,8 +253,6 @@ impl PhysicalPlanner { | |
| ) | ||
| } | ||
| ExprStruct::Subtract(expr) => { | ||
| // TODO respect ANSI eval mode | ||
| // https://github.com/apache/datafusion-comet/issues/535 | ||
| let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?; | ||
| self.create_binary_expr( | ||
| expr.left.as_ref().unwrap(), | ||
| 
        
          
        
         | 
    @@ -267,8 +264,6 @@ impl PhysicalPlanner { | |
| ) | ||
| } | ||
| ExprStruct::Multiply(expr) => { | ||
| // TODO respect ANSI eval mode | ||
| // https://github.com/apache/datafusion-comet/issues/534 | ||
| let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?; | ||
| self.create_binary_expr( | ||
| expr.left.as_ref().unwrap(), | ||
| 
        
          
        
         | 
    @@ -280,8 +275,6 @@ impl PhysicalPlanner { | |
| ) | ||
| } | ||
| ExprStruct::Divide(expr) => { | ||
| // TODO respect ANSI eval mode | ||
| // https://github.com/apache/datafusion-comet/issues/533 | ||
| let eval_mode = from_protobuf_eval_mode(expr.eval_mode)?; | ||
| self.create_binary_expr( | ||
| expr.left.as_ref().unwrap(), | ||
| 
          
            
          
           | 
    @@ -1007,21 +1000,25 @@ impl PhysicalPlanner { | |
| } | ||
| _ => { | ||
| let data_type = return_type.map(to_arrow_datatype).unwrap(); | ||
| if eval_mode == EvalMode::Try && data_type.is_integer() { | ||
| if [EvalMode::Try, EvalMode::Ansi].contains(&eval_mode) | ||
| && (data_type.is_integer() | ||
| || (data_type.is_floating() && op == DataFusionOperator::Divide)) | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the float/divide case covered by existing tests, or should a new test be added for this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for the comment. All division in comet is float or decimal division . I have had to add this check to make sure that float operands are supported only when the operation is division and the existing tests should cover this . I also have a draft PR ready for supporting Integral division #2421 which should be the ready for review once this is merged :)  | 
||
| { | ||
| let op_str = match op { | ||
| DataFusionOperator::Plus => "checked_add", | ||
| DataFusionOperator::Minus => "checked_sub", | ||
| DataFusionOperator::Multiply => "checked_mul", | ||
| DataFusionOperator::Divide => "checked_div", | ||
| _ => { | ||
| todo!("Operator yet to be implemented!"); | ||
| todo!("ANSI mode for Operator yet to be implemented!"); | ||
| } | ||
| }; | ||
| let fun_expr = create_comet_physical_fun( | ||
| let fun_expr = create_comet_physical_fun_with_eval_mode( | ||
| op_str, | ||
| data_type.clone(), | ||
| &self.session_ctx.state(), | ||
| None, | ||
| eval_mode, | ||
| )?; | ||
| Ok(Arc::new(ScalarFunctionExpr::new( | ||
| op_str, | ||
| 
          
            
          
           | 
    ||
Uh oh!
There was an error while loading. Please reload this page.