| 1033 | } |
| 1034 | |
| 1035 | Result<Expression> HandleInconsistentTypes(Expression::Call call, |
| 1036 | compute::ExecContext* exec_context) { |
| 1037 | // ARROW-18334: due to reordering of arguments, the call may have |
| 1038 | // inconsistent argument types. For example, the call's kernel may |
| 1039 | // correspond to `timestamp + duration` but the arguments happen to |
| 1040 | // be `duration, timestamp`. The addition itself is still commutative, |
| 1041 | // but the mismatch in declared argument types is potentially problematic |
| 1042 | // if we ever start using the Expression::Call::kernel field more than |
| 1043 | // we do currently. Check and rebind if necessary. |
| 1044 | // |
| 1045 | // The more correct fix for this problem is to ensure that all kernels of |
| 1046 | // functions which are commutative be commutative as well, which would |
| 1047 | // obviate rebinding like this. In the context of ARROW-18334, this |
| 1048 | // would require rewriting KernelSignature so that a single kernel can |
| 1049 | // handle both `timestamp + duration` and `duration + timestamp`. |
| 1050 | if (call.kernel->signature->MatchesInputs(GetTypes(call.arguments))) { |
| 1051 | return Expression(std::move(call)); |
| 1052 | } |
| 1053 | return BindNonRecursive(std::move(call), /*insert_implicit_casts=*/false, exec_context); |
| 1054 | } |
| 1055 | |
| 1056 | } // namespace |
| 1057 |
no test coverage detected