bkietz commented on code in PR #40200:
URL: https://github.com/apache/arrow/pull/40200#discussion_r1508990025


##########
cpp/src/arrow/compute/expression_internal.h:
##########
@@ -278,8 +278,11 @@ struct FlattenedAssociativeChain {
 
 inline Result<std::shared_ptr<compute::Function>> GetFunction(
     const Expression::Call& call, compute::ExecContext* exec_context) {
-  if (call.function_name != "cast") {
-    return exec_context->func_registry()->GetFunction(call.function_name);
+  auto input_call_function =
+      exec_context->func_registry()->GetFunction(call.function_name);
+  auto cast_function = exec_context->func_registry()->GetFunction("cast");
+  if (input_call_function != cast_function) {
+    return input_call_function;

Review Comment:
   This is not ideal since it doubles the overhead of GetFunction. Instead, 
let's add a lazily initialized `Function* FunctionRegistry::cast_function() 
const` property so that this can be rewritten
   ```suggestion
     auto function = 
exec_context->func_registry()->GetFunction(call.function_name);
     if (function != exec_context->func_registry()->cast_function()) {
       return function;
   ```



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

Reply via email to