From 3ae25734a60dfe879d4824fc8045e050521eacb5 Mon Sep 17 00:00:00 2001 From: littlegrasscao <45191106+littlegrasscao@users.noreply.github.com> Date: Wed, 15 Jan 2025 04:37:40 -0800 Subject: [PATCH] Add documentation for `{starts,ends}_with` and `split_part` (#127) Added documentation for starts_with and ends_with after exposing them to the public namespace. Updated the documentation for split_part to support negative field positions. --------- Co-authored-by: Adrian Vogelsgesang Co-authored-by: Marcel Kost --- website/docs/releases.md | 4 +++- website/docs/sql/scalar_func/string.md | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/website/docs/releases.md b/website/docs/releases.md index 03d42c8..1cd6dd3 100644 --- a/website/docs/releases.md +++ b/website/docs/releases.md @@ -26,7 +26,9 @@ In case you are wondering why all our releases start with `0.0`, read [this FAQ ### 0.0.21178 [Jan 16 2024] -* Support for Microsoft Azure Blob Storage using [`azure_location`](./sql/external/location.md#microsoft-azure-blob-storage) +* Support for Microsoft Azure Blob Storage using [`azure_location`](./sql/external/location.md#microsoft-azure-blob-storage) was added. +* Documented [`starts_with`](./sql/scalar_func/string) and [`ends_with`](./sql/scalar_func/string), as well as negative field positions for [`split_part`](./sql/scalar_func/string). + ### 0.0.20746 [Nov 7 2024] diff --git a/website/docs/sql/scalar_func/string.md b/website/docs/sql/scalar_func/string.md index a2d33f4..fced16c 100644 --- a/website/docs/sql/scalar_func/string.md +++ b/website/docs/sql/scalar_func/string.md @@ -35,6 +35,7 @@ Function|Return Type|Description|Example `concat(str "any" [, str "any" [, ...] ])`|`text`|Concatenate the text representations of all the arguments. NULL arguments are ignored, in contrast to ||.|`concat('abcde', 2, NULL, 22)` → `abcde222` `decode(string text, format text)`|`bytea`|Decode binary data from textual representation in `string`. Options for `format` are same as in `encode`.|`decode('MTIzAAE=', 'base64')` → `\x3132330001` `encode(data bytea, format text)`|`text`|Encode binary data into a textual representation. Supported formats are: `base64`, `hex`, `escape`. `escape` converts zero bytes and high-bit-set bytes to octal sequences (`\```) and doubles backslashes.|`encode('123\000\001', 'base64')` → `MTIzAAE=` +`ends_with(string text, suffix text)`|`boolean`|Return true if `string` ends with `suffix`.|`ends_with('alphabet', 'bet')` → `t` `initcap(string)`|`text`|Convert the first letter of each word to upper case and the rest to lower case. Words are sequences of alphanumeric characters separated by non-alphanumeric characters.|`initcap('hi THOMAS')` → `'Hi Thomas'` `left(str text, n int)`|`text`|Return first `` characters in the string. When `` is negative, return all but last |<n>| characters.|`left('abcde', 2)` → `'ab'` `length(string)`|`int`|Number of characters in `string`|`length('jose')` → `4` @@ -49,7 +50,8 @@ Function|Return Type|Description|Example `right(str text, n int)`|`text`|Return last `` characters in the string. When `` is negative, return all but first |<n>| characters.|`right('abcde', 2)` → `'de'` `rpad(string text, length int , fill text)`|`text`|Fill up the `string` to length `length` by appending the characters `fill` (a space by default). If the `string` is already longer than `length` then it is truncated.|`rpad('hi', 5, 'xy')` → `'hixyx'` `rtrim(string text , characters text)`|`text`|Remove the longest string containing only characters from `characters` (a space by default) from the end of `string`.|`rtrim('testxxzx', 'xyz')` → `'test'` -`split_part(string text, delimiter text, field int)`|`text`|Split `string` on `delimiter` and return the given field (counting from one).|`split_part('abc~@~def~@~ghi', '~@~', 2)` → `'def'` +`split_part(string text, delimiter text, field int)`|`text`|Split `string` on `delimiter` and return the given field (counting from one). When `n` is negative, returns the `|n|`-th-from-last field. |`split_part('abc~@~def~@~ghi', '~@~', 2)` → `'def'` +`starts_with(string text, prefix text)`|`boolean`|Return true if `string` starts with `prefix`.|`starts_with('alphabet', 'alph')` → `t` `strpos(string, substring)`|`int`|Location of specified substring (same as `position(substring in string)`, but note the reversed argument order).|`strpos('high', 'ig')` → `2` `substr(string, from , count)`|`text`|Extract substring (same as `substring(string from from for count)`).|`substr('alphabet', 3, 2)` → `'ph'` `to_hex(number int or bigint)`|`text`|Convert `number` to its equivalent hexadecimal representation.|`to_hex(2147483647)` → `'7fffffff'`