mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Fixed "timeSlot" and "timeSlots" functions [#CLICKHOUSE-4016]
This commit is contained in:
parent
6e39e021f0
commit
f8e5a22e03
@ -8,7 +8,7 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
using FunctionTimeSlot = FunctionDateOrDateTimeToSomething<DataTypeUInt32, TimeSlotImpl>;
|
||||
using FunctionTimeSlot = FunctionDateOrDateTimeToSomething<DataTypeDateTime, TimeSlotImpl>;
|
||||
|
||||
void registerFunctionTimeSlot(FunctionFactory & factory)
|
||||
{
|
||||
|
@ -121,17 +121,19 @@ public:
|
||||
|
||||
size_t getNumberOfArguments() const override { return 2; }
|
||||
|
||||
DataTypePtr getReturnTypeImpl(const DataTypes & arguments) const override
|
||||
DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override
|
||||
{
|
||||
if (!WhichDataType(arguments[0]).isDateTime())
|
||||
throw Exception("Illegal type " + arguments[0]->getName() + " of first argument of function " + getName() + ". Must be DateTime.",
|
||||
if (!WhichDataType(arguments[0].type).isDateTime())
|
||||
throw Exception("Illegal type " + arguments[0].type->getName() + " of first argument of function " + getName() + ". Must be DateTime.",
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
|
||||
if (!WhichDataType(arguments[1]).isUInt32())
|
||||
throw Exception("Illegal type " + arguments[1]->getName() + " of second argument of function " + getName() + ". Must be UInt32.",
|
||||
if (!WhichDataType(arguments[1].type).isUInt32())
|
||||
throw Exception("Illegal type " + arguments[1].type->getName() + " of second argument of function " + getName() + ". Must be UInt32.",
|
||||
ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
|
||||
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime>());
|
||||
/// If time zone is specified for source data type, attach it to the resulting type.
|
||||
/// Note that there is no explicit time zone argument for this function (we specify 2 as an argument number with explicit time zone).
|
||||
return std::make_shared<DataTypeArray>(std::make_shared<DataTypeDateTime>(extractTimeZoneNameFromFunctionArguments(arguments, 2, 0)));
|
||||
}
|
||||
|
||||
void executeImpl(Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count) override
|
||||
|
2
dbms/tests/queries/0_stateless/00734_timeslot.reference
Normal file
2
dbms/tests/queries/0_stateless/00734_timeslot.reference
Normal file
@ -0,0 +1,2 @@
|
||||
2000-01-02 03:00:00
|
||||
['2000-01-02 03:00:00','2000-01-02 03:30:00','2000-01-02 04:00:00','2000-01-02 04:30:00','2000-01-02 05:00:00','2000-01-02 05:30:00']
|
2
dbms/tests/queries/0_stateless/00734_timeslot.sql
Normal file
2
dbms/tests/queries/0_stateless/00734_timeslot.sql
Normal file
@ -0,0 +1,2 @@
|
||||
SELECT timeSlot(toDateTime('2000-01-02 03:04:05', 'UTC'));
|
||||
SELECT timeSlots(toDateTime('2000-01-02 03:04:05', 'UTC'), toUInt32(10000));
|
Loading…
Reference in New Issue
Block a user