Skip to content

Commit 6928d0e

Browse files
committed
Add documentation to source code
1 parent daa48e0 commit 6928d0e

File tree

7 files changed

+67
-11
lines changed

7 files changed

+67
-11
lines changed

src/Functions/array/arrayCount.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ You can pass a lambda function to it as the first argument.
9494
FunctionDocumentation::Syntax syntax = "arrayCount([func,] arr1, ...)";
9595
FunctionDocumentation::Arguments arguments = {
9696
{"func", "Function to apply to each element of the array(s). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)"},
97-
{"arr1 ... arrN", "N arrays"},
97+
{"arr1 ... arrN", "N arrays. [Array](/sql-reference/data-types/array)."},
9898
};
9999
FunctionDocumentation::ReturnedValue returned_value = "Returns the number of elements for which `func` returns something other than `0`. Otherwise, returns the number of non-zero elements in the array.";
100100
FunctionDocumentation::Examples example = {{"Usage example", "SELECT arrayCount(x -> (x % 2), groupArray(number) FROM numbers(10)", "5"}};

src/Functions/array/arrayPopBack.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ class FunctionArrayPopBack : public FunctionArrayPop
1515

1616
REGISTER_FUNCTION(ArrayPopBack)
1717
{
18-
factory.registerFunction<FunctionArrayPopBack>();
18+
FunctionDocumentation::Description description = "Removes the last element from the array."
19+
FunctionDocumentation::Syntax syntax = "arrayPopBack(x)";
20+
FunctionDocumentation::Arguments arguments = {{"x", "The array for which to remove the last element from. [`Array`](/sql-reference/data-types/array)."}};
21+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `x` but without the last element of `x`. [`Array`](/sql-reference/data-types/array)."
22+
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPopBack([1, 2, 3]) AS res;", "[1,2]"}};
23+
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
24+
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;
25+
FunctionDocumentation documentation = {description, syntax, arguments, returned_value, examples, introduced_in, category};
26+
27+
factory.registerFunction<FunctionArrayPopBack>(documentation);
1928
}
2029

2130
}

src/Functions/array/arrayPopFront.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ class FunctionArrayPopFront : public FunctionArrayPop
1515

1616
REGISTER_FUNCTION(ArrayPopFront)
1717
{
18-
factory.registerFunction<FunctionArrayPopFront>();
18+
FunctionDocumentation::Description description = "Removes the first item from the array."
19+
FunctionDocumentation::Syntax syntax = "arrayPopFront(x)";
20+
FunctionDocumentation::Arguments arguments = {{"x", "The array for which to remove the first element from. [`Array`](/sql-reference/data-types/array)."}};
21+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `x` but without the first element of `x`. [`Array`](/sql-reference/data-types/array).";
22+
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPopFront([1, 2, 3]) AS res;", "[2,3]"}};
23+
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
24+
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;
25+
FunctionDocumentation documentation = {description, syntax, arguments, returned_value, examples, introduced_in, category};
26+
27+
factory.registerFunction<FunctionArrayPopFront>(documentation);
1928
}
2029

2130
}

src/Functions/array/arrayPushBack.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,29 @@ class FunctionArrayPushBack : public FunctionArrayPush
1515

1616
REGISTER_FUNCTION(ArrayPushBack)
1717
{
18-
factory.registerFunction<FunctionArrayPushBack>();
18+
FunctionDocumentation::Description description = "Adds one item to the end of the array.";
19+
FunctionDocumentation::Syntax syntax = "arrayPushBack(x, y)";
20+
FunctionDocumentation::Arguments arguments = {
21+
{"x", "The array for which to add value `y` to the end of. [`Array`](/sql-reference/data-types/array)."},
22+
{"y", R"(
23+
- Single value to add to the end of the array. [`Array`](/sql-reference/data-types/array).
24+
25+
:::note
26+
- Only numbers can be added to an array with numbers, and only strings can be added to an array of strings.
27+
- When adding numbers, ClickHouse automatically sets the type of `y` for the data type of the array.
28+
- Can be `NULL`. The function adds a `NULL` element to an array, and the type of array elements converts to `Nullable`.
29+
30+
For more information about the types of data in ClickHouse, see [Data types](/sql-reference/data-types).
31+
:::
32+
)"},
33+
};
34+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `x` but with an additional value `y` at the end of the array. [`Array`](/sql-reference/data-types/array).";
35+
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPushBack(['a'], 'b') AS res;", "['a','b']"}};
36+
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
37+
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;
38+
FunctionDocumentation documentation = {description, syntax, arguments, returned_value, examples, introduced_in, category};
39+
40+
factory.registerFunction<FunctionArrayPushBack>(documentation);
1941
}
2042

2143
}

src/Functions/array/arrayPushFront.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,29 @@ class FunctionArrayPushFront : public FunctionArrayPush
1717

1818
REGISTER_FUNCTION(ArrayPushFront)
1919
{
20-
factory.registerFunction<FunctionArrayPushFront>();
20+
FunctionDocumentation::Description description = "Adds one element to the beginning of the array.";
21+
FunctionDocumentation::Syntax syntax = "arrayPushFront(x, y)";
22+
FunctionDocumentation::Arguments arguments = {
23+
{"x", "The array for which to add value `y` to the end of. [`Array`](/sql-reference/data-types/array)."},
24+
{"y", R"(
25+
- Single value to add to the start of the array. [`Array`](/sql-reference/data-types/array).
26+
27+
:::note
28+
- Only numbers can be added to an array with numbers, and only strings can be added to an array of strings.
29+
- When adding numbers, ClickHouse automatically sets the type of `y` for the data type of the array.
30+
- Can be `NULL`. The function adds a `NULL` element to an array, and the type of array elements converts to `Nullable`.
31+
32+
For more information about the types of data in ClickHouse, see [Data types](/sql-reference/data-types).
33+
:::
34+
)"},
35+
};
36+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `x` but with an additional value `y` at the beginning of the array. [`Array`](/sql-reference/data-types/array).";
37+
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPushFront(['b'], 'a') AS res;", "['a','b']"}};
38+
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
39+
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;
40+
FunctionDocumentation documentation = {description, syntax, arguments, returned_value, examples, introduced_in, category};
41+
42+
factory.registerFunction<FunctionArrayPushFront>(documentation);
2143
}
2244

2345
}

tests/queries/0_stateless/02415_all_new_functions_must_be_documented.reference

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ arrayLastOrNull
117117
arrayMap
118118
arrayMax
119119
arrayMin
120-
arrayPopBack
121-
arrayPopFront
122120
arrayProduct
123-
arrayPushBack
124-
arrayPushFront
125121
arrayROCAUC
126122
arrayRandomSample
127123
arrayReduce

tests/queries/0_stateless/02415_all_new_functions_must_have_version_information.reference

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,6 @@ arrayPartialSort
146146
arrayPopBack
147147
arrayPopFront
148148
arrayProduct
149-
arrayPushBack
150-
arrayPushFront
151149
arrayROCAUC
152150
arrayRandomSample
153151
arrayReduce

0 commit comments

Comments
 (0)