-
Notifications
You must be signed in to change notification settings - Fork 9k
Expand file tree
/
Copy patharrayPushFront.cpp
More file actions
45 lines (35 loc) · 1.95 KB
/
Copy patharrayPushFront.cpp
File metadata and controls
45 lines (35 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <Functions/array/arrayPush.h>
#include <Functions/FunctionFactory.h>
namespace DB
{
class FunctionArrayPushFront final : public FunctionArrayPush
{
public:
static constexpr auto name = "arrayPushFront";
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionArrayPushFront>(); }
FunctionArrayPushFront() : FunctionArrayPush(true, name) {}
};
REGISTER_FUNCTION(ArrayPushFront)
{
FunctionDocumentation::Description description = "Adds one element to the beginning of the array.";
FunctionDocumentation::Syntax syntax = "arrayPushFront(arr, x)";
FunctionDocumentation::Arguments arguments = {
{"arr", "The array for which to add value `x` to the end of. [`Array(T)`](/reference/data-types/array)."},
{"x", R"(
- Single value to add to the start of the array. [`Array(T)`](/reference/data-types/array).
<Note>
- Only numbers can be added to an array with numbers, and only strings can be added to an array of strings.
- When adding numbers, ClickHouse automatically sets the type of `x` for the data type of the array.
- Can be `NULL`. The function adds a `NULL` element to an array, and the type of array elements converts to `Nullable`.
For more information about the types of data in ClickHouse, see [Data types](/reference/data-types).
</Note>
)"},
};
FunctionDocumentation::ReturnedValue returned_value = {"Returns an array identical to `arr` but with an additional value `x` at the beginning of the array", {"Array(T)"}};
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPushFront(['b'], 'a') AS res;", "['a','b']"}};
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;
FunctionDocumentation documentation = {description, syntax, arguments, {}, returned_value, examples, introduced_in, category};
factory.registerFunction<FunctionArrayPushFront>(documentation);
}
}