IN operator support compare Date and Date32

This commit is contained in:
flynn 2023-04-15 12:41:42 +00:00
parent 0fbc9585f1
commit 203df96d5c
3 changed files with 22 additions and 0 deletions

View File

@ -237,6 +237,20 @@ Field convertFieldToTypeImpl(const Field & src, const IDataType & type, const ID
return src;
}
/// For toDate('xxx') in 1::Int64, we CAST `src` to UInt64, which may
/// produce wrong result in some special cases.
if (which_type.isDate() && src.getType() == Field::Types::Int64)
{
return convertNumericType<UInt64>(src, type);
}
/// For toDate32('xxx') in 1, we CAST `src` to Int64. Also, it may
/// produce wrong result in some special cases.
if (which_type.isDate32() && src.getType() == Field::Types::UInt64)
{
return convertNumericType<Int64>(src, type);
}
if (which_type.isDateTime64()
&& (src.getType() == Field::Types::UInt64 || src.getType() == Field::Types::Int64 || src.getType() == Field::Types::Decimal64))
{

View File

@ -0,0 +1,4 @@
1
1
0
0

View File

@ -0,0 +1,4 @@
select toDate32('2020-01-01') in (toDate('2020-01-01'));
select toDate('2020-01-01') in (toDate32('2020-01-01'));
select toDate('2020-01-01') in 1::Int64;
select toDate32('2020-01-01') in 1::UInt64;