From df668d62978b9c9033b1c6b5d1968ac5e1cfda4e Mon Sep 17 00:00:00 2001 From: antikvist Date: Thu, 18 Jun 2020 18:21:19 +0300 Subject: [PATCH 01/12] Rank Correlation (cherry picked from commit 3009c3885ba6317e2a1518f94a1de92e1ef2b6ed) (cherry picked from commit 024ff439e71f7164602f3e193a0c896dc1fa3fe7) --- .../AggregateFunctionRankCorr.cpp | 59 ++++ .../AggregateFunctionRankCorr.h | 290 ++++++++++++++++++ .../registerAggregateFunctions.cpp | 1 + .../registerAggregateFunctions.h | 1 + 4 files changed, 351 insertions(+) create mode 100644 src/AggregateFunctions/AggregateFunctionRankCorr.cpp create mode 100644 src/AggregateFunctions/AggregateFunctionRankCorr.h diff --git a/src/AggregateFunctions/AggregateFunctionRankCorr.cpp b/src/AggregateFunctions/AggregateFunctionRankCorr.cpp new file mode 100644 index 00000000000..d3e7ecccee2 --- /dev/null +++ b/src/AggregateFunctions/AggregateFunctionRankCorr.cpp @@ -0,0 +1,59 @@ +#include +#include +#include +#include "registerAggregateFunctions.h" + +#include +#include + + +namespace ErrorCodes +{ +extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH; +extern const int NOT_IMPLEMENTED; +} + +namespace DB +{ + +namespace +{ + +AggregateFunctionPtr createAggregateFunctionRankCorr(const std::string & name, + const DataTypes & argument_types, + const Array & parameters) +{ + assertBinary(name, argument_types); + assertNoParameters(name, parameters); + + AggregateFunctionPtr res; + + if (isDecimal(argument_types[0]) || isDecimal(argument_types[1])) + { + throw Exception("Aggregate function " + name + " only supports numerical types.", ErrorCodes::NOT_IMPLEMENTED); + } + + else + { + res.reset(createWithTwoNumericTypes(*argument_types[0], *argument_types[1], + argument_types)); + } + + + if (!res) + { + throw Exception("Aggregate function " + name + " only supports numerical types.", ErrorCodes::NOT_IMPLEMENTED); + } + + return res; +} + +} + + +void registerAggregateFunctionRankCorr(AggregateFunctionFactory & factory) +{ + factory.registerFunction("RankCorr", createAggregateFunctionRankCorr, AggregateFunctionFactory::CaseInsensitive); +} + +} \ No newline at end of file diff --git a/src/AggregateFunctions/AggregateFunctionRankCorr.h b/src/AggregateFunctions/AggregateFunctionRankCorr.h new file mode 100644 index 00000000000..4d59f3dea16 --- /dev/null +++ b/src/AggregateFunctions/AggregateFunctionRankCorr.h @@ -0,0 +1,290 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#include +#include + +#include + +namespace ErrorCodes +{ +extern const int BAD_ARGUMENTS; +} + +namespace DB +{ + +template