| 652 | } |
| 653 | |
| 654 | Result<TypeHolder> ResolveTemporalOutput(KernelContext*, |
| 655 | const std::vector<TypeHolder>& types) { |
| 656 | DCHECK_EQ(types[0].id(), types[1].id()); |
| 657 | const auto& left_type = checked_cast<const TimestampType&>(*types[0]); |
| 658 | const auto& right_type = checked_cast<const TimestampType&>(*types[1]); |
| 659 | DCHECK_EQ(left_type.unit(), left_type.unit()); |
| 660 | |
| 661 | if ((left_type.timezone() == "" || right_type.timezone() == "") && |
| 662 | left_type.timezone() != right_type.timezone()) { |
| 663 | return Status::Invalid("Subtraction of zoned and non-zoned times is ambiguous. (", |
| 664 | left_type.timezone(), right_type.timezone(), ")."); |
| 665 | } |
| 666 | |
| 667 | auto type = duration(right_type.unit()); |
| 668 | return type; |
| 669 | } |
| 670 | |
| 671 | template <typename Op> |
| 672 | void AddDecimalUnaryKernels(ScalarFunction* func) { |