mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 02:52:13 +00:00
Fixed binary operators with DateTime, now result is of same TimeZone as the DateTime operand
This commit is contained in:
parent
1acffc674d
commit
308b7bfe54
@ -823,6 +823,18 @@ public:
|
||||
type_res = std::make_shared<LeftDataType>(left.getPrecision(), left.getScale());
|
||||
else if constexpr (IsDataTypeDecimal<RightDataType>)
|
||||
type_res = std::make_shared<RightDataType>(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<ResultDataType, DataTypeDateTime>)
|
||||
{
|
||||
const TimezoneMixin * tz = nullptr;
|
||||
if constexpr (std::is_same_v<RightDataType, DataTypeDateTime>)
|
||||
tz = &right;
|
||||
if constexpr (std::is_same_v<LeftDataType, DataTypeDateTime>)
|
||||
tz = &left;
|
||||
type_res = std::make_shared<ResultDataType>(*tz);
|
||||
}
|
||||
else
|
||||
type_res = std::make_shared<ResultDataType>();
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user