houqp commented on a change in pull request #548:
URL: https://github.com/apache/arrow-datafusion/pull/548#discussion_r650450644



##########
File path: datafusion/src/physical_plan/functions.rs
##########
@@ -579,55 +575,47 @@ pub fn create_physical_expr(
                 "Unsupported data type {:?} for function btrim",
                 other,
             ))),
-        },
-        BuiltinScalarFunction::CharacterLength => |args| match 
args[0].data_type() {
-            DataType::Utf8 => {
-                let func = invoke_if_unicode_expressions_feature_flag!(
-                    character_length,
-                    Int32Type,
-                    "character_length"
-                );
-                make_scalar_function(func)(args)
-            }
-            DataType::LargeUtf8 => {
-                let func = invoke_if_unicode_expressions_feature_flag!(
-                    character_length,
-                    Int64Type,
-                    "character_length"
-                );
-                make_scalar_function(func)(args)
-            }
-            other => Err(DataFusionError::Internal(format!(
-                "Unsupported data type {:?} for function character_length",
-                other,
-            ))),
-        },
+        }),
+        BuiltinScalarFunction::CharacterLength => {
+            Arc::new(|args| match args[0].data_type() {
+                DataType::Utf8 => {
+                    let func = invoke_if_unicode_expressions_feature_flag!(
+                        character_length,
+                        Int32Type,
+                        "character_length"
+                    );
+                    make_scalar_function(func)(args)
+                }
+                DataType::LargeUtf8 => {
+                    let func = invoke_if_unicode_expressions_feature_flag!(
+                        character_length,
+                        Int64Type,
+                        "character_length"
+                    );
+                    make_scalar_function(func)(args)
+                }
+                other => Err(DataFusionError::Internal(format!(
+                    "Unsupported data type {:?} for function character_length",
+                    other,
+                ))),
+            })
+        }
         BuiltinScalarFunction::Chr => {
-            |args| make_scalar_function(string_expressions::chr)(args)
+            Arc::new(|args| 
make_scalar_function(string_expressions::chr)(args))
         }
-        BuiltinScalarFunction::Concat => string_expressions::concat,
+        BuiltinScalarFunction::Concat => Arc::new(string_expressions::concat),
         BuiltinScalarFunction::ConcatWithSeparator => {
-            |args| make_scalar_function(string_expressions::concat_ws)(args)
+            Arc::new(|args| 
make_scalar_function(string_expressions::concat_ws)(args))
         }
-        BuiltinScalarFunction::DatePart => datetime_expressions::date_part,
-        BuiltinScalarFunction::DateTrunc => datetime_expressions::date_trunc,
+        BuiltinScalarFunction::DatePart => 
Arc::new(datetime_expressions::date_part),
+        BuiltinScalarFunction::DateTrunc => 
Arc::new(datetime_expressions::date_trunc),
         BuiltinScalarFunction::Now => {
             // bind value for now at plan time
-            let fun_expr = Arc::new(datetime_expressions::make_now(
+            Arc::new(datetime_expressions::make_now(
                 ctx_state.execution_props.query_execution_start_time,
-            ));
-
-            // TODO refactor code to not return here, but instead fall through 
below

Review comment:
       This is the TODO item that gets addressed in this PR.




-- 
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to