This is an automated email from the ASF dual-hosted git repository.
jayzhan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push:
new 2d86725d29 fix docs (#13397)
2d86725d29 is described below
commit 2d86725d294d7f8bd832cff036b794808086400a
Author: Jonathan Chen <[email protected]>
AuthorDate: Wed Nov 13 19:02:46 2024 -0500
fix docs (#13397)
---
datafusion/functions-nested/src/string.rs | 14 ++++++++----
docs/source/user-guide/sql/scalar_functions.md | 30 ++++++++++++++++----------
2 files changed, 29 insertions(+), 15 deletions(-)
diff --git a/datafusion/functions-nested/src/string.rs
b/datafusion/functions-nested/src/string.rs
index 30f3845215..ce555c3627 100644
--- a/datafusion/functions-nested/src/string.rs
+++ b/datafusion/functions-nested/src/string.rs
@@ -168,16 +168,16 @@ impl ScalarUDFImpl for ArrayToString {
}
}
-static DOCUMENTATION: OnceLock<Documentation> = OnceLock::new();
+static DOCUMENTATION_ARRAY_TO_STRING: OnceLock<Documentation> =
OnceLock::new();
fn get_array_to_string_doc() -> &'static Documentation {
- DOCUMENTATION.get_or_init(|| {
+ DOCUMENTATION_ARRAY_TO_STRING.get_or_init(|| {
Documentation::builder()
.with_doc_section(DOC_SECTION_ARRAY)
.with_description(
"Converts each element to its text representation.",
)
- .with_syntax_example("array_to_string(array, delimiter)")
+ .with_syntax_example("array_to_string(array, delimiter[,
null_string])")
.with_sql_example(
r#"```sql
> select array_to_string([[1, 2, 3, 4], [5, 6, 7, 8]], ',');
@@ -196,6 +196,10 @@ fn get_array_to_string_doc() -> &'static Documentation {
"delimiter",
"Array element separator.",
)
+ .with_argument(
+ "null_string",
+ "Optional. String to replace null values in the array. If not
provided, nulls will be handled by default behavior.",
+ )
.build()
.unwrap()
})
@@ -274,8 +278,10 @@ impl ScalarUDFImpl for StringToArray {
}
}
+static DOCUMENTATION_STRING_TO_ARRAY: OnceLock<Documentation> =
OnceLock::new();
+
fn get_string_to_array_doc() -> &'static Documentation {
- DOCUMENTATION.get_or_init(|| {
+ DOCUMENTATION_STRING_TO_ARRAY.get_or_init(|| {
Documentation::builder()
.with_doc_section(DOC_SECTION_ARRAY)
.with_description(
diff --git a/docs/source/user-guide/sql/scalar_functions.md
b/docs/source/user-guide/sql/scalar_functions.md
index 74e7285b76..a379dfc9ec 100644
--- a/docs/source/user-guide/sql/scalar_functions.md
+++ b/docs/source/user-guide/sql/scalar_functions.md
@@ -3469,13 +3469,14 @@ array_sort(array, desc, nulls_first)
Converts each element to its text representation.
```
-array_to_string(array, delimiter)
+array_to_string(array, delimiter[, null_string])
```
#### Arguments
- **array**: Array expression. Can be a constant, column, or function, and any
combination of array operators.
- **delimiter**: Array element separator.
+- **null_string**: Optional. String to replace null values in the array. If
not provided, nulls will be handled by default behavior.
#### Example
@@ -3850,26 +3851,33 @@ range(start, stop, step)
### `string_to_array`
-Converts each element to its text representation.
+Splits a string into an array of substrings based on a delimiter. Any
substrings matching the optional `null_str` argument are replaced with NULL.
```
-array_to_string(array, delimiter)
+string_to_array(str, delimiter[, null_str])
```
#### Arguments
-- **array**: Array expression. Can be a constant, column, or function, and any
combination of array operators.
-- **delimiter**: Array element separator.
+- **str**: String expression to split.
+- **delimiter**: Delimiter string to split on.
+- **null_str**: Substring values to be replaced with `NULL`.
#### Example
```sql
-> select array_to_string([[1, 2, 3, 4], [5, 6, 7, 8]], ',');
-+----------------------------------------------------+
-| array_to_string(List([1,2,3,4,5,6,7,8]),Utf8(",")) |
-+----------------------------------------------------+
-| 1,2,3,4,5,6,7,8 |
-+----------------------------------------------------+
+> select string_to_array('abc##def', '##');
++-----------------------------------+
+| string_to_array(Utf8('abc##def')) |
++-----------------------------------+
+| ['abc', 'def'] |
++-----------------------------------+
+> select string_to_array('abc def', ' ', 'def');
++---------------------------------------------+
+| string_to_array(Utf8('abc def'), Utf8(' '), Utf8('def')) |
++---------------------------------------------+
+| ['abc', NULL] |
++---------------------------------------------+
```
#### Aliases
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]