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/Functions/array/arrayMap.h | |
| parent | d4ae8f119e67808cb0cf776ba6e0cf95296f2df7 (diff) | |
YQ Connector: move tests from yql to ydb (OSS)
Перенос папки с тестами на Коннектор из папки yql в папку ydb (синхронизируется с github).
Diffstat (limited to 'contrib/clickhouse/src/Functions/array/arrayMap.h')
| -rw-r--r-- | contrib/clickhouse/src/Functions/array/arrayMap.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/contrib/clickhouse/src/Functions/array/arrayMap.h b/contrib/clickhouse/src/Functions/array/arrayMap.h new file mode 100644 index 00000000000..106b62a9c9f --- /dev/null +++ b/contrib/clickhouse/src/Functions/array/arrayMap.h @@ -0,0 +1,33 @@ +#pragma once +#include "FunctionArrayMapped.h" + + +namespace DB +{ + +/** arrayMap(x1, ..., xn -> expression, array1, ..., arrayn) - apply the expression to each element of the array (or set of parallel arrays). + */ +struct ArrayMapImpl +{ + /// true if the expression (for an overload of f(expression, arrays)) or an array (for f(array)) should be boolean. + static bool needBoolean() { return false; } + /// true if the f(array) overload is unavailable. + static bool needExpression() { return true; } + /// true if the array must be exactly one. + static bool needOneArray() { return false; } + + static DataTypePtr getReturnType(const DataTypePtr & expression_return, const DataTypePtr & /*array_element*/) + { + return std::make_shared<DataTypeArray>(expression_return); + } + + static ColumnPtr execute(const ColumnArray & array, ColumnPtr mapped) + { + return ColumnArray::create(mapped->convertToFullColumnIfConst(), array.getOffsetsPtr()); + } +}; + +struct NameArrayMap { static constexpr auto name = "arrayMap"; }; +using FunctionArrayMap = FunctionArrayMapped<ArrayMapImpl, NameArrayMap>; + +} |
