mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-03 13:02:00 +00:00
fix date32 comparison with datetime/datetime64
This commit is contained in:
parent
a6937a21cf
commit
008a13df8b
@ -301,7 +301,7 @@ struct ToDateTimeImpl
|
||||
return time_zone.fromDayNum(DayNum(d));
|
||||
}
|
||||
|
||||
static inline UInt32 execute(Int32 d, const DateLUTImpl & time_zone)
|
||||
static inline Int64 execute(Int32 d, const DateLUTImpl & time_zone)
|
||||
{
|
||||
return time_zone.fromDayNum(ExtendedDayNum(d));
|
||||
}
|
||||
@ -638,7 +638,7 @@ struct ToDateTime64Transform
|
||||
inline DateTime64::NativeType execute(Int32 d, const DateLUTImpl & time_zone) const
|
||||
{
|
||||
const auto dt = ToDateTimeImpl::execute(d, time_zone);
|
||||
return execute(dt, time_zone);
|
||||
return DecimalUtils::decimalFromComponentsWithMultiplier<DateTime64>(dt, 0, scale_multiplier);
|
||||
}
|
||||
|
||||
inline DateTime64::NativeType execute(UInt32 dt, const DateLUTImpl & /*time_zone*/) const
|
||||
|
@ -216,7 +216,7 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
|
||||
}
|
||||
|
||||
if (which_type.isDateTime64()
|
||||
&& (which_from_type.isNativeInt() || which_from_type.isNativeUInt() || which_from_type.isDate() || which_from_type.isDateTime() || which_from_type.isDateTime64()))
|
||||
&& (which_from_type.isNativeInt() || which_from_type.isNativeUInt() || which_from_type.isDate() || which_from_type.isDate32() || which_from_type.isDateTime() || which_from_type.isDateTime64()))
|
||||
{
|
||||
const auto scale = static_cast<const DataTypeDateTime64 &>(type).getScale();
|
||||
const auto decimal_value = DecimalUtils::decimalFromComponents<DateTime64>(src.reinterpret<Int64>(), 0, scale);
|
||||
|
@ -6,3 +6,14 @@
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
|
@ -1,8 +1,19 @@
|
||||
select toDate32('1990-01-01') = toDate('1990-01-01');
|
||||
select toDate('1991-01-02') > toDate32('1990-01-01');
|
||||
select toDate32('1925-01-01') <= toDate('1990-01-01');
|
||||
select toDate('1991-01-01') < toDate32('2283-11-11');
|
||||
select toDate32('1990-01-01') = toDateTime('1990-01-01');
|
||||
select toDateTime('1991-01-02') > toDate32('1990-01-01');
|
||||
select toDate32('1925-01-01') <= toDateTime('1990-01-01');
|
||||
select toDateTime('1991-01-01') < toDate32('2283-11-11');
|
||||
select toDate32('1990-01-01') = toDateTime64('1990-01-01',2);
|
||||
select toDateTime64('1991-01-02',2) > toDate32('1990-01-01');
|
||||
select toDate32('1925-01-01') = toDateTime64('1925-01-01',2);
|
||||
select toDateTime64('1925-01-02',2) > toDate32('1925-01-01');
|
||||
select toDate32('2283-11-11') = toDateTime64('2283-11-11',2);
|
||||
select toDateTime64('2283-11-11',2) > toDate32('1925-01-01');
|
||||
select toDate32('1990-01-01') = '1990-01-01';
|
||||
select '1991-01-02' > toDate32('1990-01-01');
|
||||
select '1991-01-02' > toDate32('1990-01-01');
|
||||
select toDate32('1925-01-01') = '1925-01-01';
|
||||
select '2283-11-11' >= toDate32('2283-11-10');
|
||||
select '2283-11-11' > toDate32('1925-01-01');
|
Loading…
Reference in New Issue
Block a user