You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "ZhangHuiGui (via GitHub)" <gi...@apache.org> on 2024/02/21 15:15:38 UTC
[I] [C++] Cast function bind failed after add a alias name through AddAlias [arrow]
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++] Cast function bind failed after add a alias name through AddAlias [arrow]
Posted by "bkietz (via GitHub)" <gi...@apache.org>.
bkietz commented on issue #40183:
URL: https://github.com/apache/arrow/issues/40183#issuecomment-1977117901
Issue resolved by pull request 40200
https://github.com/apache/arrow/pull/40200
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++] Cast function bind failed after add a alias name through AddAlias [arrow]
Posted by "bkietz (via GitHub)" <gi...@apache.org>.
bkietz closed issue #40183: [C++] Cast function bind failed after add a alias name through AddAlias
URL: https://github.com/apache/arrow/issues/40183
--
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: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org