kou commented on code in PR #47297:
URL: https://github.com/apache/arrow/pull/47297#discussion_r2268307177
##########
cpp/src/arrow/compute/kernel.cc:
##########
@@ -475,23 +475,78 @@ std::string OutputType::ToString() const {
return "computed";
}
+// ----------------------------------------------------------------------
+// MatchConstraint
+
+std::shared_ptr<MatchConstraint> DecimalsHaveSameScale() {
+ class DecimalsHaveSameScaleConstraint : public MatchConstraint {
+ public:
+ bool Matches(const std::vector<TypeHolder>& types) const override {
+ DCHECK_GE(types.size(), 2);
+ DCHECK(std::all_of(types.begin(), types.end(),
+ [](const TypeHolder& type) { return
is_decimal(type.id()); }));
+ auto ty0 = checked_cast<const DecimalType*>(types[0].type);
+ DCHECK_NE(ty0, nullptr);
Review Comment:
I thought that `checked_cast` never return `nullptr` because there are
`static_assert()`s before `dynamic_cast`:
https://github.com/apache/arrow/blob/db1a8a9bf42bec2b643fc19d8e174dd5166cd621/cpp/src/arrow/util/checked_cast.h#L29-L34
BTW, there is
```cpp
DCHECK(std::all_of(types.begin(), types.end(),
[](const TypeHolder& type) { return
is_decimal(type.id()); }));
```
before this `checked_cast`. It seems that this `DCHECK()` will be failed
when `checked_cast` return `nullptr`.
--
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]