From 136f7c3d8a6bd9bc0ce389bb5cf297d47a246435 Mon Sep 17 00:00:00 2001 From: Dimitri Vorona Date: Thu, 7 Nov 2024 18:11:46 +0100 Subject: [PATCH] Release 2024.11 (#129) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add upcoming release section * Prepare the September 2024 release * Update commit hash (missing character) * Prepare for the Nov 2024 release * Document additional array functions (#130) --------- Co-authored-by: André Kohn Co-authored-by: Marcel Kost Co-authored-by: Adrian Vogelsgesang --- website/docs/releases.md | 6 ++ website/docs/sql/scalar_func/arrays.md | 5 +- website/docs/sql/setreturning.md | 136 +++++++++++++++---------- website/src/config.ts | 2 +- 4 files changed, 94 insertions(+), 55 deletions(-) diff --git a/website/docs/releases.md b/website/docs/releases.md index fb4065f..a69791a 100644 --- a/website/docs/releases.md +++ b/website/docs/releases.md @@ -24,6 +24,12 @@ In case you are wondering why all our releases start with `0.0`, read [this FAQ ::: +### 0.0.20746 [Nov 7 2024] + +* Support for `array_contains`, `array_position` and `array_positions` was added +* Support for the `unnest` set-returning function was added +* Various performance and stability improvements + ### 0.0.20027 [Aug 19 2024] * Introduced new [`array` SQL datatypes](./sql/datatype/array.md). diff --git a/website/docs/sql/scalar_func/arrays.md b/website/docs/sql/scalar_func/arrays.md index 4f95dcc..00d2d88 100644 --- a/website/docs/sql/scalar_func/arrays.md +++ b/website/docs/sql/scalar_func/arrays.md @@ -13,7 +13,10 @@ Signature|Description|Example array(T)**[**int**]** → `T`| Returns the n-th element of the array (1-indexed). | `(array[1,2,3])[1]` → `1` array(T)**[**int**:**int**]** → `T` | Returns the subarray within the given boundes (1-indexed, inclusive). |`(array[1,2,3])[2:3]` → `{2,3}` | **array_length(**array**)** → `int` | Returns the length of the array. | `array_length(array[1,2,3])` → `3` -**array_to_string(**array, text [, text]**)**| Converts the array into a textual representation, with the given element separator and (optional) null indicator. | `array_to_string(array[1,2,3], ';')` → `1;2;3`
`array_to_string(array[3,2,1,null], '⏰', '🎉')` → `3⏰2⏰1⏰🎉` +**array_to_string(**array, text [, text]**)**| Converts the array into a textual representation, with the given element separator and (optional) null indicator. | `array_to_string(array[1,2,3], ';')` → `1;2;3`
`array_to_string(array[3,2,1,null], '⏰', '🎉')` → `3⏰2⏰1⏰🎉` +**array_contains(**array, value**)**| Checks if a given value is contained within the array. | `array_contains(array[1,3,4], 3)` → `true`
`array_contains(array[1,3,4], 2)` → `false` +**array_position(**array, value**)**| Returns the index of the first occurrence of `value` inside `array`. Comparisons are done using `IS NOT DISTINCT FROM` semantics, so it is possible to search for `NULL`. Returns `NULL` if the element is not found. | `array_position(array[1,3,4,3], 3)` → `2`
`array_contains(array[1,3,4,3], 2)` → `NULL` +**array_positions(**array, value**)**| Returns the an array containing the indices of all occurrences of `value` inside `array`. Comparisons are done using `IS NOT DISTINCT FROM` semantics, so it is possible to search for `NULL`. `NULL` is returned only if the array is `NULL`; if the value is not found in the array, an empty array is returned. | `array_positions(array[1,3,4,3], 3)` → `[2,4]`
`array_contains(array[1,3,4,3], 2)` → `[]` ## Transformations The following functions produce new array values from existing ones. diff --git a/website/docs/sql/setreturning.md b/website/docs/sql/setreturning.md index a71e913..54c3f7f 100644 --- a/website/docs/sql/setreturning.md +++ b/website/docs/sql/setreturning.md @@ -4,6 +4,89 @@ This section describes functions that possibly return more than one row. Set returning functions are usually used in SQL queries in the [FROM clause](command/select#from). +## `generate_series` + +Generate a series of values, from `start` to `stop` with a given `step` size + +```sql_template +`generate_series(, [, ])` +``` + +If `step` is not specified, the default step size of `1` will be used. +When `step` is positive, zero rows are returned if `start` is greater +than `stop`. Conversely, when `step` is negative, zero rows are returned +if `start` is less than `stop`. Zero rows are also returned for `NULL` +inputs. It is an error for `step` to be zero. Some examples follow: + + SELECT * FROM generate_series(2,4); + generate_series + ----------------- + 2 + 3 + 4 + (3 rows) + + SELECT * FROM generate_series(5,1,-2); + generate_series + ----------------- + 5 + 3 + 1 + (3 rows) + + SELECT * FROM generate_series(4,3); + generate_series + ----------------- + (0 rows) + + SELECT generate_series(1.1, 4, 1.3); + generate_series + ----------------- + 1.1 + 2.4 + 3.7 + (3 rows) + + -- this example relies on the date-plus-integer operator + SELECT current_date + s.a AS dates FROM generate_series(0,14,7) AS s(a); + dates + ------------ + 2004-02-05 + 2004-02-12 + 2004-02-19 + (3 rows) + +## `unnest` {#unnest} + +The `unnest` function expands the elements from an array: + + SELECT * FROM unnest(ARRAY['Mon','Tue','Wed','Thu','Fri']) + unnest + ----------------- + Mon + Tue + Wed + Thu + Fri + (5 rows) + +`unnest` can also be called with multiple array paramters (potentially of different data types). In this case, the arrays are expanded pairwise. If the arrays are not all the same length then the shorter ones are padded with NULLs. + + SELECT * FROM unnest( + ARRAY['Mon','Tue','Wed','Thu','Fri'], + ARRAY[1,2,3,4,5,6,7] + ) AS days(name, nr); + name | nr + ------+---- + Mon | 1 + Tue | 2 + Wed | 3 + Thu | 4 + Fri | 5 + NULL | 6 + NULL | 7 + (7 rows) + ## `external` {#external} The `external` function reads data stored in an external file format @@ -89,56 +172,3 @@ Same but with explicit Amazon S3 credentials and bucket region: region => 'us-east-1' ) ) WHERE price > 100; - -## `generate_series` - -Generate a series of values, from `start` to `stop` with a given `step` size - -```sql_template -`generate_series(, [, ])` -``` - -If `step` is not specified, the default step size of `1` will be used. -When `step` is positive, zero rows are returned if `start` is greater -than `stop`. Conversely, when `step` is negative, zero rows are returned -if `start` is less than `stop`. Zero rows are also returned for `NULL` -inputs. It is an error for `step` to be zero. Some examples follow: - - SELECT * FROM generate_series(2,4); - generate_series - ----------------- - 2 - 3 - 4 - (3 rows) - - SELECT * FROM generate_series(5,1,-2); - generate_series - ----------------- - 5 - 3 - 1 - (3 rows) - - SELECT * FROM generate_series(4,3); - generate_series - ----------------- - (0 rows) - - SELECT generate_series(1.1, 4, 1.3); - generate_series - ----------------- - 1.1 - 2.4 - 3.7 - (3 rows) - - -- this example relies on the date-plus-integer operator - SELECT current_date + s.a AS dates FROM generate_series(0,14,7) AS s(a); - dates - ------------ - 2004-02-05 - 2004-02-12 - 2004-02-19 - (3 rows) - diff --git a/website/src/config.ts b/website/src/config.ts index bef927d..48970dd 100644 --- a/website/src/config.ts +++ b/website/src/config.ts @@ -1,4 +1,4 @@ -const version_long = '0.0.20027.rcc745c2c'; +const version_long = '0.0.20746.reac9bd2d'; const version_short = version_long.substr(0, version_long.lastIndexOf('.')); const downloadBaseUrl = 'https://downloads.tableau.com/tssoftware/';