ZhangHuiGui commented on code in PR #41363:
URL: https://github.com/apache/arrow/pull/41363#discussion_r1577895599
##########
cpp/src/arrow/compute/kernels/scalar_if_else.cc:
##########
@@ -1195,6 +1195,43 @@ struct ResolveIfElseExec<NullType, AllocateMem> {
}
};
+template <typename ResolverForOtherTypes>
+Result<TypeHolder> ResolveDecimalCaseType(KernelContext* ctx,
+ const std::vector<TypeHolder>& types,
+ ResolverForOtherTypes&& resolver) {
+ if (!HasDecimal(types)) {
+ return resolver(ctx, types);
+ }
+
+ int32_t max_precision = 0, max_scale = 0;
+ for (auto& type : types) {
+ if (is_floating(type.id()) || is_integer(type.id())) {
+ return Status::Invalid("Need to cast numeric types containing decimal
types");
+ } else if (is_decimal(type.id())) {
+ const auto& decimal_type = checked_cast<const
arrow::DecimalType&>(*type);
+ if (decimal_type.precision() < max_precision || decimal_type.scale() <
max_scale) {
Review Comment:
In `BindNonRecursive`:
`FinishBind` will do output type resolve. For the first time go into the
resolver, our decimal related types haven't cast, we could check if the decimal
types have different precision and scale.
And then return invalid to make the `BindNonRecursive` go into `IfElse`'s
related function's `DispatchBest` and do cast.
After that, when we go into type resolver in `BindNoRecursive` second time,
we could find the decimal types already cast to same precision and scale, so we
could find the correct result output type.
--
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]