Skip to content

Commit 1094d25

Browse files
committed
stop using the '␣' to denote a space character in function examples
1 parent 37d5767 commit 1094d25

File tree

2 files changed

+21
-30
lines changed

2 files changed

+21
-30
lines changed

docs/preview/sql/functions/text.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ This section describes functions and operators for examining and manipulating [`
5959
| [`like_escape(string, like_specifier, escape_character)`](#like_escapestring-like_specifier-escape_character) | Returns `true` if the `string` matches the `like_specifier` (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})) using case-sensitive matching. `escape_character` is used to search for wildcard characters in the `string`. |
6060
| [`lower(string)`](#lowerstring) | Converts `string` to lower case. |
6161
| [`lpad(string, count, character)`](#lpadstring-count-character) | Pads the `string` with the `character` on the left until it has `count` characters. Truncates the `string` on the right if it has more than `count` characters. |
62-
| [`ltrim(string[, characters])`](#ltrimstring-characters) | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
62+
| [`ltrim(string[, characters])`](#ltrimstring-characters) | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. |
6363
| [`md5(string)`](#md5string) | Returns the MD5 hash of the `string` as a `VARCHAR`. |
6464
| [`md5_number(string)`](#md5_numberstring) | Returns the MD5 hash of the `string` as a `HUGEINT`. |
65-
| [`md5_number_lower(string)`](#md5_number_lowerstring) | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
66-
| [`md5_number_upper(string)`](#md5_number_upperstring) | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
65+
| [`md5_number_lower(string)`](#md5_number_lowerstring) | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
66+
| [`md5_number_upper(string)`](#md5_number_upperstring) | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
6767
| [`nfc_normalize(string)`](#nfc_normalizestring) | Converts `string` to Unicode NFC normalized string. Useful for comparisons and ordering if text data is mixed between NFC normalized and not. |
6868
| [`not_ilike_escape(string, like_specifier, escape_character)`](#not_ilike_escapestring-like_specifier-escape_character) | Returns `false` if the `string` matches the `like_specifier` (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})) using case-insensitive matching. `escape_character` is used to search for wildcard characters in the `string`. |
6969
| [`not_like_escape(string, like_specifier, escape_character)`](#not_like_escapestring-like_specifier-escape_character) | Returns `false` if the `string` matches the `like_specifier` (see [Pattern Matching]({% link docs/preview/sql/functions/pattern_matching.md %})) using case-sensitive matching. `escape_character` is used to search for wildcard characters in the `string`. |
@@ -91,7 +91,7 @@ This section describes functions and operators for examining and manipulating [`
9191
| [`right(string, count)`](#rightstring-count) | Extract the right-most `count` characters. |
9292
| [`right_grapheme(string, count)`](#right_graphemestring-count) | Extracts the right-most `count` grapheme clusters. |
9393
| [`rpad(string, count, character)`](#rpadstring-count-character) | Pads the `string` with the `character` on the right until it has `count` characters. Truncates the `string` on the right if it has more than `count` characters. |
94-
| [`rtrim(string[, characters])`](#rtrimstring-characters) | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
94+
| [`rtrim(string[, characters])`](#rtrimstring-characters) | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. |
9595
| [`sha1(value)`](#sha1value) | Returns a `VARCHAR` with the SHA-1 hash of the `value`. |
9696
| [`sha256(value)`](#sha256value) | Returns a `VARCHAR` with the SHA-256 hash of the `value` |
9797
| [`split(string, separator)`](#splitstring-separator) | Splits the `string` along the `separator`. |
@@ -109,12 +109,12 @@ This section describes functions and operators for examining and manipulating [`
109109
| [`substring(string, start[, length])`](#substringstring-start-length) | Extracts substring starting from character `start` up to the end of the string. If optional argument `length` is set, extracts a substring of `length` characters instead. Note that a `start` value of `1` refers to the first character of the `string`. |
110110
| [`substring_grapheme(string, start[, length])`](#substring_graphemestring-start-length) | Extracts substring starting from grapheme clusters `start` up to the end of the string. If optional argument `length` is set, extracts a substring of `length` grapheme clusters instead. Note that a `start` value of `1` refers to the `first` character of the `string`. |
111111
| [`suffix(string, search_string)`](#suffixstring-search_string) | Returns `true` if `string` ends with `search_string`. |
112-
| [`to_base(number, raxid[, min_length])`](#to_basenumber-raxid-min_length) | Converts `number` to a string in the given base `radix`, optionally padding with leading zeros to `min_length`. |
112+
| [`to_base(number, radix[, min_length])`](#to_basenumber-radix-min_length) | Converts `number` to a string in the given base `radix`, optionally padding with leading zeros to `min_length`. |
113113
| [`to_base64(blob)`](#to_base64blob) | Converts a `blob` to a base64 encoded string. |
114114
| [`to_binary(string)`](#to_binarystring) | Converts the `string` to binary representation. |
115115
| [`to_hex(string)`](#to_hexstring) | Converts the `string` to hexadecimal representation. |
116116
| [`translate(string, from, to)`](#translatestring-from-to) | Replaces each character in `string` that matches a character in the `from` set with the corresponding character in the `to` set. If `from` is longer than `to`, occurrences of the extra characters in `from` are deleted. |
117-
| [`trim(string[, characters])`](#trimstring-characters) | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
117+
| [`trim(string[, characters])`](#trimstring-characters) | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. |
118118
| [`ucase(string)`](#ucasestring) | Converts `string` to upper case. |
119119
| [`unbin(value)`](#unbinvalue) | Converts a `value` from binary representation to a blob. |
120120
| [`unhex(value)`](#unhexvalue) | Converts a `value` from hexadecimal representation to a blob. |
@@ -216,7 +216,7 @@ This section describes functions and operators for examining and manipulating [`
216216

217217
| **Description** | Draws a band whose width is proportional to (`x - min`) and equal to `width` characters when `x` = `max`. `width` defaults to 80. |
218218
| **Example** | `bar(5, 0, 20, 10)` |
219-
| **Result** | `██▌␣␣␣␣␣␣␣` |
219+
| **Result** | `██▌ ` |
220220

221221
#### `base64(blob)`
222222

@@ -497,9 +497,9 @@ This section describes functions and operators for examining and manipulating [`
497497

498498
<div class="nostroke_table"></div>
499499

500-
| **Description** | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
501-
| **Example 1** | `ltrim('␣␣␣␣test␣␣')` |
502-
| **Result** | `test␣␣` |
500+
| **Description** | Removes any occurrences of any of the `characters` from the left side of the `string`. `characters` defaults to `space`. |
501+
| **Example 1** | `ltrim(' test ')` |
502+
| **Result** | `test ` |
503503
| **Example 2** | `ltrim('>>>>test<<', '><')` |
504504
| **Result** | `test<<` |
505505

@@ -523,15 +523,15 @@ This section describes functions and operators for examining and manipulating [`
523523

524524
<div class="nostroke_table"></div>
525525

526-
| **Description** | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
526+
| **Description** | Returns the lower 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
527527
| **Example** | `md5_number_lower('abc')` |
528528
| **Result** | `8250560606382298838` |
529529

530530
#### `md5_number_upper(string)`
531531

532532
<div class="nostroke_table"></div>
533533

534-
| **Description** | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `BIGINT`. |
534+
| **Description** | Returns the upper 64-bit segment of the MD5 hash of the `string` as a `UBIGINT`. |
535535
| **Example** | `md5_number_upper('abc')` |
536536
| **Result** | `12704604231530709392` |
537537

@@ -758,9 +758,9 @@ This section describes functions and operators for examining and manipulating [`
758758

759759
<div class="nostroke_table"></div>
760760

761-
| **Description** | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
762-
| **Example 1** | `rtrim('␣␣␣␣test␣␣')` |
763-
| **Result** | `␣␣␣␣test` |
761+
| **Description** | Removes any occurrences of any of the `characters` from the right side of the `string`. `characters` defaults to `space`. |
762+
| **Example 1** | `rtrim(' test ')` |
763+
| **Result** | ` test` |
764764
| **Example 2** | `rtrim('>>>>test<<', '><')` |
765765
| **Result** | `>>>>test` |
766766

@@ -917,7 +917,9 @@ This section describes functions and operators for examining and manipulating [`
917917
| **Result** | `true` |
918918
| **Alias** | `ends_with` |
919919

920-
#### `to_base(number, raxid[, min_length])`
920+
#### `to_base(number, radix[, min_length])`
921+
922+
<div class="nostroke_table"></div>
921923

922924
| **Description** | Converts `number` to a string in the given base `radix`, optionally padding with leading zeros to `min_length`. |
923925
| **Example** | `to_base(42, 16, 5)` |
@@ -962,8 +964,8 @@ This section describes functions and operators for examining and manipulating [`
962964

963965
<div class="nostroke_table"></div>
964966

965-
| **Description** | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. In the example, the `` symbol denotes a space character. |
966-
| **Example 1** | `trim('␣␣␣␣test␣␣')` |
967+
| **Description** | Removes any occurrences of any of the `characters` from either side of the `string`. `characters` defaults to `space`. |
968+
| **Example 1** | `trim(' test ')` |
967969
| **Result** | `test` |
968970
| **Example 2** | `trim('>>>>test<<', '><')` |
969971
| **Result** | `test` |

scripts/generate_sql_function_docs.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,7 @@ def generate_example_rows(func: DocFunction):
383383
try:
384384
if func.name in BINARY_OPERATORS:
385385
example = f"({example})"
386-
run_example = re.sub(r'␣', ' ', example)
387-
query_result = duckdb.sql(rf"select {run_example}::VARCHAR").fetchall()
386+
query_result = duckdb.sql(rf"select {example}::VARCHAR").fetchall()
388387
if len(query_result) != 1:
389388
example_result = 'Multiple rows: ' + ', '.join(
390389
(
@@ -398,16 +397,6 @@ def generate_example_rows(func: DocFunction):
398397
example_result = (
399398
f"{query_result[0][0]}" if query_result[0][0] else "NULL"
400399
)
401-
# replace leading and trailing spaces by '␣'
402-
nr_leading_spaces = 0
403-
nr_trailing_spaces = 0
404-
while example_result and example_result[0] == ' ':
405-
example_result = example_result[1:]
406-
nr_leading_spaces += 1
407-
while example_result and example_result[-1] == ' ':
408-
example_result = example_result[:-1]
409-
nr_trailing_spaces += 1
410-
example_result = f"{nr_leading_spaces * '␣'}{example_result}{nr_trailing_spaces * '␣'}"
411400
except duckdb.ParserException as e:
412401
print(
413402
f"Error for function '{func.name}', could not calculate example: '{example}'. Consider adding it via OVERRIDES'. {e}"

0 commit comments

Comments
 (0)