Skip to content

Commit c850d03

Browse files
committed
Review feedback
1 parent 2869b79 commit c850d03

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

src/Functions/array/arrayFill.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,16 +131,14 @@ REGISTER_FUNCTION(ArrayFill)
131131
FunctionDocumentation::Description description = R"(
132132
The `arrayFill` function sequentially processes a source array from the first element
133133
to the last, evaluating a lambda condition at each position using elements from
134-
the source and condition arrays. When the condition evaluates to false at
134+
the source and condition arrays. When the lambda function evaluates to false at
135135
position i, the function replaces that element with the element at position i-1
136136
from the current state of the array. The first element is always preserved
137137
regardless of any condition.
138-
139-
`arrayFill` is a [higher-order function](/sql-reference/functions/overview#higher-order-functions). You must pass a lambda function to it as the first argument, and it can't be omitted.
140138
)";
141-
FunctionDocumentation::Syntax syntax = "arrayFill(λ(x [, y1, ..., yN]), source [, cond1, ... , condN])";
139+
FunctionDocumentation::Syntax syntax = "arrayFill(func(x [, y1, ..., yN]), source [, cond1, ... , condN])";
142140
FunctionDocumentation::Arguments arguments = {
143-
{"λ(x [, y1, ..., yN])", "A lambda function `λ(x [, y1, y2, ... yN]) → F(x [, y1, y2, ... yN])` which operates on elements of the source array (`x`) and condition arrays (`y`). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)."},
141+
{"func(x [, y1, ..., yN])", "A lambda function `func(x [, y1, y2, ... yN]) → F(x [, y1, y2, ... yN])` which operates on elements of the source array (`x`) and condition arrays (`y`). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)."},
144142
{"source", "The source array to process [`Array(T)`](/sql-reference/data-types/array)."},
145143
{"[, cond1, ... , condN]", "Optional. N condition arrays providing additional arguments to the lambda function. [`Array(T)`](/sql-reference/data-types/array)."},
146144
};
@@ -162,16 +160,14 @@ from the source and condition arrays. When the condition evaluates to false at
162160
position i, the function replaces that element with the element at position i+1
163161
from the current state of the array. The last element is always preserved
164162
regardless of any condition.
165-
166-
`arrayReverseFill` is a [higher-order function](/sql-reference/functions/overview#higher-order-functions). You must pass a lambda function to it as the first argument, and it can't be omitted.
167163
)";
168-
FunctionDocumentation::Syntax syntax_reverse = "arrayReverseFill(λ(x [, y1, ..., yN]), source [, cond1, ... , condN])";
164+
FunctionDocumentation::Syntax syntax_reverse = "arrayReverseFill(func(x[, y1, ..., yN]), source[, cond1, ... , condN])";
169165
FunctionDocumentation::Arguments arguments_reverse = {
170-
{"λ(x [, y1, ..., yN])", "A lambda function `λ(x [, y1, y2, ... yN]) → F(x [, y1, y2, ... yN])` which operates on elements of the source array (`x`) and condition arrays (`y`). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)."},
166+
{"func(x[, y1, ..., yN])", "A lambda function which operates on elements of the source array (`x`) and condition arrays (`y`). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)."},
171167
{"source", "The source array to process [`Array(T)`](/sql-reference/data-types/array)."},
172168
{"[, cond1, ... , condN]", "Optional. N condition arrays providing additional arguments to the lambda function. [`Array(T)`](/sql-reference/data-types/array)."},
173169
};
174-
FunctionDocumentation::ReturnedValue returned_value_reverse = "Returns an array with replaced elements. [`Array(T)`](/sql-reference/data-types/array).";
170+
FunctionDocumentation::ReturnedValue returned_value_reverse = "Returns an array with elements of the source array replaced by the results of the lambda. [`Array(T)`](/sql-reference/data-types/array).";
175171
FunctionDocumentation::Examples examples_reverse = {
176172
{"Example with a single array", "SELECT arrayReverseFill(x -> not isNull(x), [1, null, 2, null]) AS res", "[1,2,2,NULL]"},
177173
{"Example with two arrays", "SELECT arrayReverseFill(x, y, z -> x > y AND x < z, [5, 3, 6, 2], [4, 7, 1, 3], [10, 2, 8, 5]) AS res;", "[5,6,6,2]"}

src/Functions/array/arrayFilter.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,14 @@ ColumnPtr ArrayFilterImpl::execute(const ColumnArray & array, ColumnPtr mapped)
4949

5050
REGISTER_FUNCTION(ArrayFilter)
5151
{
52-
FunctionDocumentation::Description description = "Returns an array containing only the elements in `arrN` for which `func(arr1[i], ..., arrN[i])` return something other than `0`.";
53-
FunctionDocumentation::Syntax syntax = "arrayFilter(func, arr1 [, arr2, ... , arrN)]";
52+
FunctionDocumentation::Description description = "Returns an array containing only the elements in the source array for which a lambda function returns something other than `0`.";
53+
FunctionDocumentation::Syntax syntax = "arrayFilter(func(x[, y1, ..., yN]), source[, cond1, ... , condN])]";
5454
FunctionDocumentation::Arguments arguments = {
55-
{"func", "Function to apply to each element of the array(s). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)"},
56-
{"arr1 [, arr2, ... , arrN)]", "N arrays over which to operate. [`Array(T)`](/sql-reference/data-types/array)."},
55+
{"func(x[, y1, ..., yN])", "A lambda function which operates on elements of the source array (`x`) and condition arrays (`y`). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)."},
56+
{"source", "The source array to process [`Array(T)`](/sql-reference/data-types/array)."},
57+
{"[, cond1, ... , condN]", "Optional. N condition arrays providing additional arguments to the lambda function. [`Array(T)`](/sql-reference/data-types/array)."},
5758
};
58-
FunctionDocumentation::ReturnedValue returned_value = "Returns a filtered array. [`Array(T)`](/sql-reference/data-types/array).";
59+
FunctionDocumentation::ReturnedValue returned_value = "Returns a subset of the source array. [`Array(T)`](/sql-reference/data-types/array).";
5960
FunctionDocumentation::Examples examples = {
6061
{"Example 1", "SELECT arrayFilter(x -> x LIKE '%World%', ['Hello', 'abc World']) AS res", "['abc World']"},
6162
{"Example 2", R"(

src/Functions/array/arrayMap.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ namespace DB
77
REGISTER_FUNCTION(ArrayMap)
88
{
99
FunctionDocumentation::Description description = R"(
10-
Returns an array obtained from the original arrays by application of `func(arr1[i], ..., arrN[i])` for each element.
11-
Arrays `arr1` ... `arrN` must have the same number of elements.
12-
13-
`arrayMap` is a [higher-order function](/sql-reference/functions/overview#higher-order-functions). You must pass a lambda function to it as the first argument, and it can't be omitted.
10+
Returns an array obtained from the original arrays by applying a lambda function to each element.
1411
)";
15-
FunctionDocumentation::Syntax syntax = "arrayMap(func, arr1 [, ..., arrN])";
12+
FunctionDocumentation::Syntax syntax = "arrayMap(func, arr)";
1613
FunctionDocumentation::Arguments arguments = {
17-
{"func", "Function to apply to each element of the array(s). Optional. [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)"},
18-
{"arr1 [, ..., arrN]", "N arrays to apply `f` to. [Array(T)](/sql-reference/data-types/array)."},
14+
{"func", "A lambda function which operates on elements of the source array (`x`) and condition arrays (`y`). [Lambda function](/sql-reference/functions/overview#arrow-operator-and-lambda)."},
15+
{"arr", "N arrays to process. [Array(T)](/sql-reference/data-types/array)."},
1916
};
20-
FunctionDocumentation::ReturnedValue returned_value = "Returns an array with elements the results of applying `f` to the original array. [`Array(T)`](/sql-reference/data-types/array)";
17+
FunctionDocumentation::ReturnedValue returned_value = "Returns an array from the lambda results. [`Array(T)`](/sql-reference/data-types/array)";
2118
FunctionDocumentation::Examples examples = {
2219
{"Usage example", "SELECT arrayMap(x -> (x + 2), [1, 2, 3]) as res;", "[3,4,5]"},
2320
{"Creating a tuple of elements from different arrays", "SELECT arrayMap((x, y) -> (x, y), [1, 2, 3], [4, 5, 6]) AS res", "[(1,4),(2,5),(3,6)]"}

0 commit comments

Comments
 (0)