zanmato1984 commented on code in PR #50870:
URL: https://github.com/apache/arrow/pull/50870#discussion_r3910982585
##########
cpp/src/arrow/compute/kernel.cc:
##########
@@ -519,6 +519,22 @@ std::shared_ptr<MatchConstraint> DecimalsHaveSameScale() {
return instance;
}
+std::shared_ptr<MatchConstraint> AllTypesAreIdenticalFrom(size_t
first_type_index) {
+ return MatchConstraint::Make(
+ [first_type_index](const std::vector<TypeHolder>& types) -> bool {
+ DCHECK_LT(first_type_index, types.size());
+ return std::all_of(types.begin() + first_type_index + 1, types.end(),
+ [&types, first_type_index](const TypeHolder& type) {
+ return type == types[first_type_index];
+ });
+ });
Review Comment:
Thanks. This follows the existing `MatchConstraint` precondition style:
`DecimalsHaveSameScale()` likewise uses `DCHECK` for both the minimum input
count and the input kinds. In the normal dispatch path,
`Function::CheckArity()` validates the argument count and the per-input
signature checks run before the constraint; the current callers guarantee at
least one input for `AllTypesAreIdentical()` and at least two for
`AllTypesAreIdenticalFrom(1)`.
Therefore, a shorter `types` vector would be a caller contract violation
rather than a runtime input condition. I would prefer to keep the `DCHECK` here
for consistency. Making all public constraints defensive could be considered
separately, including `DecimalsHaveSameScale()`.
--
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]