| 498 | } |
| 499 | |
| 500 | std::shared_ptr<MatchConstraint> DecimalsHaveSameScale() { |
| 501 | class DecimalsHaveSameScaleConstraint : public MatchConstraint { |
| 502 | public: |
| 503 | bool Matches(const std::vector<TypeHolder>& types) const override { |
| 504 | DCHECK_GE(types.size(), 2); |
| 505 | DCHECK(std::all_of(types.begin(), types.end(), |
| 506 | [](const TypeHolder& type) { return is_decimal(type.id()); })); |
| 507 | const auto& ty0 = checked_cast<const DecimalType&>(*types[0].type); |
| 508 | auto s0 = ty0.scale(); |
| 509 | for (size_t i = 1; i < types.size(); ++i) { |
| 510 | const auto& ty = checked_cast<const DecimalType&>(*types[i].type); |
| 511 | if (ty.scale() != s0) { |
| 512 | return false; |
| 513 | } |
| 514 | } |
| 515 | return true; |
| 516 | } |
| 517 | }; |
| 518 | static auto instance = std::make_shared<DecimalsHaveSameScaleConstraint>(); |
| 519 | return instance; |
| 520 | } |
| 521 | |
| 522 | // ---------------------------------------------------------------------- |
| 523 | // KernelSignature |
no outgoing calls