diff --git a/dbms/src/Functions/FunctionBinaryArithmetic.h b/dbms/src/Functions/FunctionBinaryArithmetic.h index 233598370ad..63961cc0bb7 100644 --- a/dbms/src/Functions/FunctionBinaryArithmetic.h +++ b/dbms/src/Functions/FunctionBinaryArithmetic.h @@ -823,6 +823,18 @@ public: type_res = std::make_shared(left.getPrecision(), left.getScale()); else if constexpr (IsDataTypeDecimal) type_res = std::make_shared(right.getPrecision(), right.getScale()); + // Special case for DateTime: binary OPS should not looze the timezone of the result type, + // but reuse timezone of DateTime argument. + // NOTE: binary plus/minus are not allowed on DateTime64, and we are not handling it here. + else if constexpr (std::is_same_v) + { + const TimezoneMixin * tz = nullptr; + if constexpr (std::is_same_v) + tz = &right; + if constexpr (std::is_same_v) + tz = &left; + type_res = std::make_shared(*tz); + } else type_res = std::make_shared(); return true;