ZhangHuiGui opened a new issue, #40183:
URL: https://github.com/apache/arrow/issues/40183

   ### Describe the bug, including details regarding any error messages, 
version, and platform.
   
   ## How to reproduce
   ```c
   auto fm = arrow::compute::GetFunctionRegistry();
   ASSERT_OK(fm->AddAlias("alias_cast", "cast"));
   auto s1 = arrow::schema({arrow::field("f1", arrow::decimal128(30, 3))});
   auto b = arrow::RecordBatchFromJSON(s1, R"([
       ["1.000"],
       ["-4567.890"]
   ])");
   auto expr = arrow::compute::call("alias_cast", 
{arrow::compute::field_ref("f1")}, 
           arrow::compute::CastOptions::Unsafe(arrow::int32()));
   ASSERT_OK_AND_ASSIGN(expr, expr.Bind(*s1)); // Bind failed
   
   ASSERT_OK_AND_ASSIGN(auto input, arrow::compute::MakeExecBatch(*s1, b));
   ASSERT_OK_AND_ASSIGN(auto res_dat,
                        arrow::compute::ExecuteScalarExpression(expr, input));
   ```
   
   Bind failed with `NotImplemented: Dispatch for a MetaFunction's Kernels`.
   
   ## Reason
   `BindNonRecursive` will call  `arrow::compute::GetFunction`, the function 
handle the cast with specific name and
   return an original function object rather than `CastFunction` which override 
the `DispatchExact`.
   ```c
   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);
     }
     // XXX this special case is strange; why not make "cast" a ScalarFunction?
     const TypeHolder& to_type =
         ::arrow::internal::checked_cast<const 
compute::CastOptions&>(*call.options).to_type;
     return GetCastFunction(*to_type);
   }
   ```
   It's a huge project for us to unify the CastFunction schedule path to 
standard `ScalarFunction`, so i think maybe we should forbidden AddAlias for 
`cast`?
   
   
   ### Component(s)
   
   C++


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