-
Notifications
You must be signed in to change notification settings - Fork 9k
Expand file tree
/
Copy patharrayPushBack.cpp
More file actions
43 lines (35 loc) · 1.89 KB
/
Copy patharrayPushBack.cpp
File metadata and controls
43 lines (35 loc) · 1.89 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
#include <Functions/array/arrayPush.h>
#include <Functions/FunctionFactory.h>
namespace DB
{
class FunctionArrayPushBack final : public FunctionArrayPush
{
public:
static constexpr auto name = "arrayPushBack";
static FunctionPtr create(ContextPtr) { return std::make_shared<FunctionArrayPushBack>(); }
FunctionArrayPushBack() : FunctionArrayPush(false, name) {}
};
REGISTER_FUNCTION(ArrayPushBack)
{
FunctionDocumentation::Description description = "Adds one item to the end of the array.";
FunctionDocumentation::Syntax syntax = "arrayPushBack(arr, x)";
FunctionDocumentation::Arguments arguments = {
{"arr", "The array for which to add value `x` to the end of.", {"Array(T)"}},
{"x", R"(
- Single value to add to the end 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 end of the array", {"Array(T)"}};
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPushBack(['a'], 'b') 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<FunctionArrayPushBack>(documentation);
}
}