Skip to content

Commit f8053df

Browse files
Apply suggestions from code review
Co-authored-by: Jason Stirnaman <jstirnaman@influxdata.com>
1 parent b30319d commit f8053df

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

content/shared/sql-reference/functions/array.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ _Alias of [empty](#empty)._
336336

337337
## array_except
338338

339-
Returns an array of elements that appear in the first array but not in the second.
339+
Returns an array containing elements from the first array that are not present in the second array.
340340

341341
```sql
342342
array_except(array1, array2)
@@ -441,7 +441,7 @@ SELECT array_has_all([1, 2, 3, 4], [2, 3]) AS array_has_all
441441

442442
## array_has_any
443443

444-
Returns `true` if any elements exist in both arrays.
444+
Returns `true` if at least one element appears in both arrays.
445445

446446
```sql
447447
array_has_any(array, sub-array)
@@ -479,7 +479,7 @@ _Alias of [array_position](#array_position)._
479479

480480
## array_intersect
481481

482-
Returns an array of elements in the intersection of **array1** and **array2**.
482+
Returns an array containing only the elements that appear in both **array1** and **array2**.
483483

484484
```sql
485485
array_intersect(array1, array2)
@@ -1107,7 +1107,8 @@ SELECT array_replace_n(['John', 'Jane', 'James', 'John', 'John'], 'John', 'Joe',
11071107
## array_resize
11081108

11091109
Resizes the list to contain size elements. Initializes new elements with value
1110-
or empty if value is not set.
1110+
Resizes the array to the specified size. If expanding, fills new elements with the
1111+
specified value (or _NULL_ if not provided). If shrinking, truncates excess elements.
11111112

11121113
```sql
11131114
array_resize(array, size, value)
@@ -1269,7 +1270,7 @@ SELECT
12691270

12701271
## array_to_string
12711272

1272-
Converts an array to string-based representation with a specified delimiter.
1273+
Converts an array to a string by joining all elements with the specified delimiter.
12731274

12741275
```sql
12751276
array_to_string(array, delimiter[, null_string])
@@ -1318,7 +1319,8 @@ SELECT array_to_string([[1,2,3,4,5,NULL,7,8,NULL]], '-', '?') AS array_to_string
13181319
## array_union
13191320

13201321
Returns an array of elements that are present in both arrays (all elements from
1321-
both arrays) with out duplicates.
1322+
Returns an array containing all unique elements from both input arrays, with
1323+
duplicates removed.
13221324

13231325
```sql
13241326
array_union(array1, array2)
@@ -1414,12 +1416,12 @@ SELECT empty(['apple']) AS empty
14141416

14151417
## flatten
14161418

1417-
Converts an array of arrays to a flat array.
1419+
Flattens nested arrays into a single-level array.
14181420

1419-
- Applies to any depth of nested arrays
1420-
- Does not change arrays that are already flat
1421+
- Recursively flattens arrays at any depth of nesting
1422+
- Returns unchanged if the array is already flat
14211423

1422-
The flattened array contains all the elements from all source arrays.
1424+
The result contains all elements from all nested arrays in a single flat array.
14231425

14241426
```sql
14251427
flatten(array)

content/shared/sql-reference/functions/map.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ _Alias of [map_extract](#map_extract)._
1515

1616
## make_map
1717

18-
Returns an Arrow map with the specified key-value pair.
18+
Returns an Arrow map with the specified key and value.
1919

2020
```sql
2121
make_map(key, value)
@@ -62,6 +62,8 @@ Each _key_ must be unique and non-null.
6262

6363
```sql
6464
map(key_list, value_list)
65+
-- or
66+
map { key: value, ... }
6567
```
6668

6769
### Arguments
@@ -142,7 +144,9 @@ SELECT
142144
## map_extract
143145

144146
Returns a list containing the value for the given key or an empty list if the
145-
key is not present in the map.
147+
Returns a list containing the value for the given key, or an empty list if the
148+
key is not present in the map. The returned list will contain exactly one element
149+
(the value) when the key is found.
146150

147151
```sql
148152
map_extract(map, key)
@@ -176,9 +180,9 @@ to perform the a query that:
176180
- Queries the weather sample data and use `date_part` to extract an integer
177181
representing the day of the week of the row's `time` value.
178182
- Uses `map_extract` and the output of `date_part` to return an array containing
179-
the name of the data of the week.
183+
the name of the day of the week.
180184
- Uses bracket notation (`[i]`) to reference an element by index in the returned
181-
list (lists are 1-indexed).
185+
list (SQL arrays are 1-indexed, so `[1]` retrieves the first element).
182186

183187
```sql
184188
WITH constants AS (

content/shared/sql-reference/functions/struct.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ _Alias of [`struct`](#struct)._
5858

5959
Returns an _Arrow struct_ using the specified input expressions optionally named.
6060
Fields in the returned struct use the optional name or the `cN` naming convention.
61-
For example: `c0`, `c1`, `c2`, etc.
61+
Fields in the returned struct use the `cN` naming convention (for example: `c0`, `c1`, `c2`, etc.)
62+
unless you specify custom names using the `AS` operator within individual expressions.
6263

6364
```sql
6465
struct(expression1[, ..., expression_n])
@@ -67,7 +68,7 @@ struct(expression1[, ..., expression_n])
6768
### Arguments
6869

6970
- **expression1, expression_n**: Expression to include in the output struct.
70-
Can be a constant, column, or function, any combination of arithmetic or
71+
Can be a constant, column, or function, and any combination of arithmetic or
7172
string operators.
7273

7374
### Aliases
@@ -86,7 +87,7 @@ _The following example uses the
8687

8788
```sql
8889
SELECT
89-
struct('time', time, 'temperature', temp, 'humidity', hum) AS struct
90+
struct(time, temp, hum) AS struct
9091
FROM
9192
home
9293
WHERE

0 commit comments

Comments
 (0)