Skip to content

Commit eb79c9b

Browse files
committed
Edits based on review comments
1 parent b657ef9 commit eb79c9b

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

content/en/logs/workspaces/sql_reference.md

+19-21
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,18 @@ The following SQL functions are supported. For Window function, see the separate
9292
| `trim(string s)` | string | Removes leading and trailing whitespace from the string. |
9393
| `replace(string s, string from, string to)` | string | Replaces occurrences of a substring within a string with another substring. |
9494
| `substring(string s, int start, int length)` | string | Extracts a substring from a string, starting at a given position and for a specified length. |
95-
| `strpos(string s, string substring)` | integer | Returns the index position of the substring in a given string. |
96-
| `split_part(string s, string delimiter, integer index)` | string | Splits the string on the given delimiter and returns the string as the given position counting from 1. |
95+
| `strpos(string s, string substring)` | integer | Returns the first index position of the substring in a given string, or 0 if there is no match |
96+
| `split_part(string s, string delimiter, integer index)` | string | Splits the string on the given delimiter and returns the string at the given position counting from one. |
9797
| `extract(unit from timestamp/interval)` | numeric | Extracts a part of a date or time field (such as year or month) from a timestamp or interval. |
9898
| `to_timestamp(string timestamp, string format)` | timestamp | Converts a string to a timestamp according to the given format. |
9999
| `to_char(timestamp t, string format)` | string | Converts a timestamp to a string according to the given format. |
100100
| `date_trunc(string unit, timestamp t)` | timestamp | Truncates a timestamp to a specified precision based on the provided unit. |
101101
| `regexp_like(string s, pattern p)` | boolean | Evaluates if a string matches a regular expression pattern. |
102-
| `cardinality(array a)` | integer | Returns the number of elements in the array, or 0 if the array is empty. |
103-
| `array_position(array a, typeof_array value)` | integer | Returns the index of the first occurence of the value found in the array. |
102+
| `cardinality(array a)` | integer | Returns the number of elements in the array. |
103+
| `array_position(array a, typeof_array value)` | integer | Returns the index of the first occurrence of the value found in the array, or null if value is not found. |
104104
| `string_to_array(string s, string delimiter)` | array of strings | Splits the given string into an array of strings using the given delimiter. |
105-
| `array_agg(expression e)` | array of input type | Create an array by concatenating the input values. Ordering is not deterministic |
106-
| `unnest(array a)` | type of array | Expands an array into a set of rows. |
105+
| `array_agg(expression e)` | array of input type | Creates an array by collecting all the input values. |
106+
| `unnest(array a [, array b...])` | type of array | Expands arrays into a set of rows. This form is only allowed in a FROM clause. |
107107

108108
{{% collapse-content title="Examples" level="h3" %}}
109109

@@ -240,7 +240,7 @@ FROM
240240
### `STRPOS`
241241
{{< code-block lang="sql" >}}
242242
SELECT
243-
STRPOS('high', 'ig')
243+
STRPOS('foobar', 'bar')
244244
{{< /code-block >}}
245245

246246
### `SPLIT_PART`
@@ -381,26 +381,24 @@ SELECT
381381
### `ARRAY_AGG`
382382
{{< code-block lang="sql" >}}
383383
SELECT
384-
ARRAY_AGG(x) arr1,
385-
ARRAY_AGG(all x) arr2,
386-
ARRAY_AGG(distinct x) arr3,
387-
ARRAY_AGG(y) arr4
388-
FROM (
389-
SELECT 1 x, 4.1 y
390-
UNION ALL
391-
SELECT 2 x, 5.1 y
392-
UNION ALL
393-
SELECT 2 x, 6.1 y
394-
);
384+
sender,
385+
ARRAY_AGG(subject) subjects,
386+
ARRAY_AGG(ALL subject) all_subjects,
387+
ARRAY_AGG(DISTINCT subject) distinct_subjects
388+
FROM
389+
emails
390+
GROUP BY
391+
sender
395392
{{< /code-block >}}
396393

397394
### `UNNEST`
398395
{{< code-block lang="sql" >}}
399396
SELECT
400-
*,
401-
UNNEST(recipients)
397+
sender,
398+
recipient
402399
FROM
403-
emails;
400+
emails,
401+
UNNEST(recipients) AS recipient
404402
{{< /code-block >}}
405403

406404
{{% /collapse-content %}}

0 commit comments

Comments
 (0)