mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Re-enable Date and Date32 as parameters of toUnixTimestamp function
This commit is contained in:
parent
86e14547d4
commit
83d066e5cf
@ -145,13 +145,6 @@ struct ConvertImpl
|
||||
using ColVecFrom = typename FromDataType::ColumnType;
|
||||
using ColVecTo = typename ToDataType::ColumnType;
|
||||
|
||||
if (std::is_same_v<Name, NameToUnixTimestamp>)
|
||||
{
|
||||
if (isDateOrDate32(named_from.type))
|
||||
throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Illegal type {} of first argument of function {}",
|
||||
named_from.type->getName(), Name::name);
|
||||
}
|
||||
|
||||
if constexpr ((IsDataTypeDecimal<FromDataType> || IsDataTypeDecimal<ToDataType>)
|
||||
&& !(std::is_same_v<DataTypeDateTime64, FromDataType> || std::is_same_v<DataTypeDateTime64, ToDataType>))
|
||||
{
|
||||
@ -306,6 +299,8 @@ struct ConvertImpl
|
||||
{
|
||||
if constexpr (std::is_same_v<ToDataType, DataTypeIPv4> && std::is_same_v<FromDataType, DataTypeUInt64>)
|
||||
vec_to[i] = static_cast<ToFieldType>(static_cast<IPv4::UnderlyingType>(vec_from[i]));
|
||||
else if constexpr (std::is_same_v<Name, NameToUnixTimestamp> && (std::is_same_v<FromDataType, DataTypeDate> || std::is_same_v<FromDataType, DataTypeDate32>))
|
||||
vec_to[i] = static_cast<ToFieldType>(vec_from[i] * 86400);
|
||||
else
|
||||
vec_to[i] = static_cast<ToFieldType>(vec_from[i]);
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
1683676800
|
||||
1683676800
|
||||
1683676800
|
||||
1683676800
|
@ -1 +1,4 @@
|
||||
select toUnixTimestamp(today()); -- { serverError 44 }
|
||||
select toUnixTimestamp(makeDate(2023, 5, 10));
|
||||
select toUnixTimestamp(makeDate32(2023, 5, 10));
|
||||
select toUnixTimestamp(makeDate(2023, 5, 10), 'Pacific/Auckland');
|
||||
select toUnixTimestamp(makeDate32(2023, 5, 10), 'Pacific/Auckland');
|
Loading…
Reference in New Issue
Block a user