Skip to content

Commit 4d642b3

Browse files
committed
Review changes
1 parent 85b13c1 commit 4d642b3

14 files changed

+54
-72
lines changed

src/Functions/array/arrayCount.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,12 @@ REGISTER_FUNCTION(ArrayCount)
8585
Returns the number of elements for which `func(arr1[i], ..., arrN[i])` returns something other than `0`.
8686
If `func` is not specified, it returns the number of non-zero elements in the array.
8787
88-
:::note
89-
Note that the `arrayCount` is a [higher-order function](/sql-reference/functions/overview#higher-order-functions).
90-
You can pass a lambda function to it as the first argument.
91-
:::
92-
88+
`arrayCount` is a [higher-order function](/sql-reference/functions/overview#higher-order-functions).
9389
)";
94-
FunctionDocumentation::Syntax syntax = "arrayCount([func,] arr1, ...)";
90+
FunctionDocumentation::Syntax syntax = "arrayCount([func, ] arr1, ...)";
9591
FunctionDocumentation::Arguments arguments = {
96-
{"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. [Array](/sql-reference/data-types/array)."},
92+
{"func", "Function to apply to each element of the array(s). Optional. [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)"},
93+
{"arr1, ..., arrN", "N arrays. [Array(T)](/sql-reference/data-types/array)."},
9894
};
9995
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.";
10096
FunctionDocumentation::Examples example = {{"Usage example", "SELECT arrayCount(x -> (x % 2), groupArray(number) FROM numbers(10)", "5"}};

src/Functions/array/arrayDotProduct.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,14 @@ REGISTER_FUNCTION(ArrayDotProduct)
388388
FunctionDocumentation::Description description = R"(
389389
Returns the dot product of two arrays.
390390
391-
Aliases: `scalarProduct`, `dotProduct`
392-
393391
:::note
394392
The sizes of the two vectors must be equal. Arrays and Tuples may also contain mixed element types.
395393
:::
396394
)";
397395
FunctionDocumentation::Syntax syntax = "arrayDotProduct(v1, v2)";
398396
FunctionDocumentation::Arguments arguments = {
399-
{"v1", "First vector. [Array](/sql-reference/data-types/array) or [Tuple](../data-types/tuple.md) of numeric values."},
400-
{"v2", "Second vector. [Array](/sql-reference/data-types/array) or [Tuple](../data-types/tuple.md) of numeric values."},
397+
{"v1", "First vector. [Array(T)](/sql-reference/data-types/array) or [Tuple(T1, T2, ...)](../data-types/tuple.md) of numeric values."},
398+
{"v2", "Second vector. [Array(T)](/sql-reference/data-types/array) or [Tuple(T1, T2, ...)](../data-types/tuple.md) of numeric values."},
401399
};
402400
FunctionDocumentation::ReturnedValue returned_value = R"(
403401
The dot product of the two vectors. [Numeric](/native-protocol/columns#numeric-types).
@@ -410,7 +408,7 @@ The return type is determined by the type of the arguments. If Arrays or Tuples
410408
{"Array example", "SELECT arrayDotProduct([1, 2, 3], [4, 5, 6]) AS res, toTypeName(res);", "32 UInt16"},
411409
{"Tuple example", "SELECT dotProduct((1::UInt16, 2::UInt8, 3::Float32),(4::Int16, 5::Float32, 6::UInt8)) AS res, toTypeName(res);", "32 Float64"}
412410
};
413-
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
411+
FunctionDocumentation::IntroducedIn introduced_in = {23, 5};
414412
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;
415413
FunctionDocumentation documentation = {description, syntax, arguments, returned_value, examples, introduced_in, category};
416414

src/Functions/array/arrayEnumerate.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ This function is normally used with the [`ARRAY JOIN`](/sql-reference/statements
8383
once for each array after applying `ARRAY JOIN`.
8484
This function can also be used in higher-order functions. For example, you can use it to get array indexes for elements that match a condition.
8585
)";
86-
FunctionDocumentation::Syntax syntax = "arrayEnumerate(x)";
86+
FunctionDocumentation::Syntax syntax = "arrayEnumerate(arr)";
8787
FunctionDocumentation::Arguments arguments = {
88-
{"x", "The array to enumerate. [`Array`](/sql-reference/data-types/array)."}
88+
{"arr", "The array to enumerate. [`Array`](/sql-reference/data-types/array)."}
8989
};
9090
FunctionDocumentation::ReturnedValue returned_value = "Returns the array `[1, 2, 3, ..., length (arr)]`. Array(UInt32)";
9191
FunctionDocumentation::Examples examples = {{"Basic example with ARRAY JOIN", R"(

src/Functions/array/arrayEnumerateUniqRanked.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ SELECT arrayEnumerateUniqRanked(2, [[1,2,3],[2,2,1],[3]], 2);
6262
```
6363
)", "[[1,1,1],[1,2,1],[1]]"},
6464
};
65-
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
65+
FunctionDocumentation::IntroducedIn introduced_in = {20, 1};
6666
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;
6767
FunctionDocumentation documentation = {description, syntax, arguments, returned_value, examples, introduced_in, category};
6868

src/Functions/array/arrayPopBack.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class FunctionArrayPopBack : public FunctionArrayPop
1616
REGISTER_FUNCTION(ArrayPopBack)
1717
{
1818
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).";
19+
FunctionDocumentation::Syntax syntax = "arrayPopBack(arr)";
20+
FunctionDocumentation::Arguments arguments = {{"arr", "The array for which to remove the last element from. [`Array(T)`](/sql-reference/data-types/array)."}};
21+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `arr` but without the last element of `arr`. [`Array(T)`](/sql-reference/data-types/array).";
2222
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPopBack([1, 2, 3]) AS res;", "[1,2]"}};
2323
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
2424
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;

src/Functions/array/arrayPopFront.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class FunctionArrayPopFront : public FunctionArrayPop
1616
REGISTER_FUNCTION(ArrayPopFront)
1717
{
1818
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).";
19+
FunctionDocumentation::Syntax syntax = "arrayPopFront(arr)";
20+
FunctionDocumentation::Arguments arguments = {{"arr", "The array for which to remove the first element from. [`Array(T)`](/sql-reference/data-types/array)."}};
21+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `arr` but without the first element of `arr`. [`Array(T)`](/sql-reference/data-types/array).";
2222
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPopFront([1, 2, 3]) AS res;", "[2,3]"}};
2323
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
2424
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;

src/Functions/array/arrayPushBack.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ class FunctionArrayPushBack : public FunctionArrayPush
1616
REGISTER_FUNCTION(ArrayPushBack)
1717
{
1818
FunctionDocumentation::Description description = "Adds one item to the end of the array.";
19-
FunctionDocumentation::Syntax syntax = "arrayPushBack(x, y)";
19+
FunctionDocumentation::Syntax syntax = "arrayPushBack(arr, x)";
2020
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).
21+
{"arr", "The array for which to add value `x` to the end of. [`Array(T)`](/sql-reference/data-types/array)."},
22+
{"x", R"(
23+
- Single value to add to the end of the array. [`Array(T)`](/sql-reference/data-types/array).
2424
2525
:::note
2626
- 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.
27+
- When adding numbers, ClickHouse automatically sets the type of `x` for the data type of the array.
2828
- Can be `NULL`. The function adds a `NULL` element to an array, and the type of array elements converts to `Nullable`.
2929
3030
For more information about the types of data in ClickHouse, see [Data types](/sql-reference/data-types).
3131
:::
3232
)"},
3333
};
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).";
34+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `arr` but with an additional value `x` at the end of the array. [`Array(T)`](/sql-reference/data-types/array).";
3535
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPushBack(['a'], 'b') AS res;", "['a','b']"}};
3636
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
3737
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;

src/Functions/array/arrayPushFront.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ class FunctionArrayPushFront : public FunctionArrayPush
1818
REGISTER_FUNCTION(ArrayPushFront)
1919
{
2020
FunctionDocumentation::Description description = "Adds one element to the beginning of the array.";
21-
FunctionDocumentation::Syntax syntax = "arrayPushFront(x, y)";
21+
FunctionDocumentation::Syntax syntax = "arrayPushFront(arr, x)";
2222
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).
23+
{"arr", "The array for which to add value `x` to the end of. [`Array(T)`](/sql-reference/data-types/array)."},
24+
{"x", R"(
25+
- Single value to add to the start of the array. [`Array(T)`](/sql-reference/data-types/array).
2626
2727
:::note
2828
- 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.
29+
- When adding numbers, ClickHouse automatically sets the type of `x` for the data type of the array.
3030
- Can be `NULL`. The function adds a `NULL` element to an array, and the type of array elements converts to `Nullable`.
3131
3232
For more information about the types of data in ClickHouse, see [Data types](/sql-reference/data-types).
3333
:::
3434
)"},
3535
};
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).";
36+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array identical to `arr` but with an additional value `x` at the beginning of the array. [`Array(T)`](/sql-reference/data-types/array).";
3737
FunctionDocumentation::Examples examples = {{"Usage example", "SELECT arrayPushFront(['b'], 'a') AS res;", "['a','b']"}};
3838
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
3939
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;

src/Functions/array/countEqual.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Returns the number of elements in the array equal to `x`. Equivalent to `arrayCo
1616
)";
1717
FunctionDocumentation::Syntax syntax = "countEqual(arr, x)";
1818
FunctionDocumentation::Arguments arguments = {
19-
{"arr", "Array to search. [`Array`](/sql-reference/data-types/array)."},
19+
{"arr", "Array to search. [`Array(T)`](/sql-reference/data-types/array)."},
2020
{"x", "Value in the array to count. Any type."}
2121
};
22-
FunctionDocumentation::ReturnedValue returned_value = "Returns the number of elements in the array equal to `x`. UInt64.";
22+
FunctionDocumentation::ReturnedValue returned_value = "Returns the number of elements in the array equal to `x`. [UInt64](/sql-reference/data-types/int-uint).";
2323
FunctionDocumentation::Examples example = {{"Usage example", "SELECT countEqual([1, 2, NULL, NULL], NULL)", "2"}};
2424
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};
2525
FunctionDocumentation::Category category = FunctionDocumentation::Category::Array;

src/Functions/array/hasAll.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,14 @@ Checks whether one array is a subset of another.
3232
- `1`, if `set` contains all of the elements from `subset`.
3333
- `0`, otherwise.
3434
35-
Raises an exception `NO_COMMON_TYPE` if the set and subset elements do not share a common supertype.
35+
Raises a `NO_COMMON_TYPE` exception if the set and subset elements do not share a common supertype.
3636
)";
3737
FunctionDocumentation::Examples examples = {
3838
{"Empty arrays", "SELECT hasAll([], [])", "1"},
3939
{"Arrays containing NULL values", "SELECT hasAll([1, Null], [Null])", "1"},
4040
{"Arrays containing values of a different type", "SELECT hasAll([1.0, 2, 3, 4], [1, 3])", "1"},
4141
{"Arrays containing String values", "SELECT hasAll(['a', 'b'], ['a'])", "1"},
42-
{"Arrays without a common type", "SELECT hasAll([1], ['a'])", R"(
43-
Received exception:
44-
Code: 386. DB::Exception:
45-
There is no supertype for types UInt8, String because some of them are String/FixedString/Enum and some of them are not:
46-
In scope SELECT hasAll([1], ['a']). (NO_COMMON_TYPE
47-
)"},
42+
{"Arrays without a common type", "SELECT hasAll([1], ['a'])", "Raises a NO_COMMON_TYPE exception"},
4843
{"Array of arrays", "SELECT hasAll([[1, 2], [3, 4]], [[1, 2], [3, 5]])", "0"},
4944
};
5045
FunctionDocumentation::IntroducedIn introduced_in = {1, 1};

0 commit comments

Comments
 (0)