diff options
| author | vitalyisaev <[email protected]> | 2023-11-14 09:58:56 +0300 |
|---|---|---|
| committer | vitalyisaev <[email protected]> | 2023-11-14 10:20:20 +0300 |
| commit | c2b2dfd9827a400a8495e172a56343462e3ceb82 (patch) | |
| tree | cd4e4f597d01bede4c82dffeb2d780d0a9046bd0 /contrib/clickhouse/src/AggregateFunctions/AggregateFunctionDeltaSumTimestamp.cpp | |
| parent | d4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff) | |
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/AggregateFunctions/AggregateFunctionDeltaSumTimestamp.cpp')
| -rw-r--r-- | contrib/clickhouse/src/AggregateFunctions/AggregateFunctionDeltaSumTimestamp.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/AggregateFunctions/AggregateFunctionDeltaSumTimestamp.cpp b/contrib/clickhouse/src/AggregateFunctions/AggregateFunctionDeltaSumTimestamp.cpp new file mode 100644 index 00000000000..6c07e34668f --- /dev/null +++ b/contrib/clickhouse/src/AggregateFunctions/AggregateFunctionDeltaSumTimestamp.cpp @@ -0,0 +1,52 @@ +#include <AggregateFunctions/AggregateFunctionDeltaSumTimestamp.h> + +#include <AggregateFunctions/AggregateFunctionFactory.h> +#include <AggregateFunctions/FactoryHelpers.h> +#include <AggregateFunctions/Helpers.h> + + +namespace DB +{ + +namespace ErrorCodes +{ + extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; + extern const int ILLEGAL_TYPE_OF_ARGUMENT; +} + +namespace +{ + +AggregateFunctionPtr createAggregateFunctionDeltaSumTimestamp( + const String & name, + const DataTypes & arguments, + const Array & params, + const Settings *) +{ + assertNoParameters(name, params); + + if (arguments.size() != 2) + throw Exception(ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH, + "Incorrect number of arguments for aggregate function {}", name); + + if (!isInteger(arguments[0]) && !isFloat(arguments[0]) && !isDate(arguments[0]) && !isDateTime(arguments[0])) + throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for aggregate function {}, " + "must be Int, Float, Date, DateTime", arguments[0]->getName(), name); + + if (!isInteger(arguments[1]) && !isFloat(arguments[1]) && !isDate(arguments[1]) && !isDateTime(arguments[1])) + throw Exception(ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT, "Illegal type {} of argument for aggregate function {}, " + "must be Int, Float, Date, DateTime", arguments[1]->getName(), name); + + return AggregateFunctionPtr(createWithTwoNumericOrDateTypes<AggregationFunctionDeltaSumTimestamp>( + *arguments[0], *arguments[1], arguments, params)); +} +} + +void registerAggregateFunctionDeltaSumTimestamp(AggregateFunctionFactory & factory) +{ + AggregateFunctionProperties properties = { .returns_default_when_only_null = true, .is_order_dependent = true }; + + factory.registerFunction("deltaSumTimestamp", { createAggregateFunctionDeltaSumTimestamp, properties }); +} + +} |
