Skip to content

Commit 2d86725

Browse files
authored
fix docs (#13397)
1 parent ccf6258 commit 2d86725

File tree

2 files changed

+29
-15
lines changed

2 files changed

+29
-15
lines changed

datafusion/functions-nested/src/string.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,16 @@ impl ScalarUDFImpl for ArrayToString {
168168
}
169169
}
170170

171-
static DOCUMENTATION: OnceLock<Documentation> = OnceLock::new();
171+
static DOCUMENTATION_ARRAY_TO_STRING: OnceLock<Documentation> = OnceLock::new();
172172

173173
fn get_array_to_string_doc() -> &'static Documentation {
174-
DOCUMENTATION.get_or_init(|| {
174+
DOCUMENTATION_ARRAY_TO_STRING.get_or_init(|| {
175175
Documentation::builder()
176176
.with_doc_section(DOC_SECTION_ARRAY)
177177
.with_description(
178178
"Converts each element to its text representation.",
179179
)
180-
.with_syntax_example("array_to_string(array, delimiter)")
180+
.with_syntax_example("array_to_string(array, delimiter[, null_string])")
181181
.with_sql_example(
182182
r#"```sql
183183
> select array_to_string([[1, 2, 3, 4], [5, 6, 7, 8]], ',');
@@ -196,6 +196,10 @@ fn get_array_to_string_doc() -> &'static Documentation {
196196
"delimiter",
197197
"Array element separator.",
198198
)
199+
.with_argument(
200+
"null_string",
201+
"Optional. String to replace null values in the array. If not provided, nulls will be handled by default behavior.",
202+
)
199203
.build()
200204
.unwrap()
201205
})
@@ -274,8 +278,10 @@ impl ScalarUDFImpl for StringToArray {
274278
}
275279
}
276280

281+
static DOCUMENTATION_STRING_TO_ARRAY: OnceLock<Documentation> = OnceLock::new();
282+
277283
fn get_string_to_array_doc() -> &'static Documentation {
278-
DOCUMENTATION.get_or_init(|| {
284+
DOCUMENTATION_STRING_TO_ARRAY.get_or_init(|| {
279285
Documentation::builder()
280286
.with_doc_section(DOC_SECTION_ARRAY)
281287
.with_description(

docs/source/user-guide/sql/scalar_functions.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3469,13 +3469,14 @@ array_sort(array, desc, nulls_first)
34693469
Converts each element to its text representation.
34703470

34713471
```
3472-
array_to_string(array, delimiter)
3472+
array_to_string(array, delimiter[, null_string])
34733473
```
34743474

34753475
#### Arguments
34763476

34773477
- **array**: Array expression. Can be a constant, column, or function, and any combination of array operators.
34783478
- **delimiter**: Array element separator.
3479+
- **null_string**: Optional. String to replace null values in the array. If not provided, nulls will be handled by default behavior.
34793480

34803481
#### Example
34813482

@@ -3850,26 +3851,33 @@ range(start, stop, step)
38503851

38513852
### `string_to_array`
38523853

3853-
Converts each element to its text representation.
3854+
Splits a string into an array of substrings based on a delimiter. Any substrings matching the optional `null_str` argument are replaced with NULL.
38543855

38553856
```
3856-
array_to_string(array, delimiter)
3857+
string_to_array(str, delimiter[, null_str])
38573858
```
38583859

38593860
#### Arguments
38603861

3861-
- **array**: Array expression. Can be a constant, column, or function, and any combination of array operators.
3862-
- **delimiter**: Array element separator.
3862+
- **str**: String expression to split.
3863+
- **delimiter**: Delimiter string to split on.
3864+
- **null_str**: Substring values to be replaced with `NULL`.
38633865

38643866
#### Example
38653867

38663868
```sql
3867-
> select array_to_string([[1, 2, 3, 4], [5, 6, 7, 8]], ',');
3868-
+----------------------------------------------------+
3869-
| array_to_string(List([1,2,3,4,5,6,7,8]),Utf8(",")) |
3870-
+----------------------------------------------------+
3871-
| 1,2,3,4,5,6,7,8 |
3872-
+----------------------------------------------------+
3869+
> select string_to_array('abc##def', '##');
3870+
+-----------------------------------+
3871+
| string_to_array(Utf8('abc##def')) |
3872+
+-----------------------------------+
3873+
| ['abc', 'def'] |
3874+
+-----------------------------------+
3875+
> select string_to_array('abc def', ' ', 'def');
3876+
+---------------------------------------------+
3877+
| string_to_array(Utf8('abc def'), Utf8(' '), Utf8('def')) |
3878+
+---------------------------------------------+
3879+
| ['abc', NULL] |
3880+
+---------------------------------------------+
38733881
```
38743882

38753883
#### Aliases

0 commit comments

Comments
 (0)