From 683de7d66f17a962842bb72208d94a96624b0e73 Mon Sep 17 00:00:00 2001 From: Cheng-Yuan-Lai Date: Fri, 27 Dec 2024 00:39:02 +0800 Subject: [PATCH 1/7] doc-gen: migrate scalar functions (string) documentation 2/4 --- datafusion/functions/src/string/concat.rs | 51 +++++++--------- datafusion/functions/src/string/concat_ws.rs | 59 ++++++++----------- datafusion/functions/src/string/ends_with.rs | 58 ++++++++---------- .../functions/src/string/levenshtein.rs | 49 ++++++++------- datafusion/functions/src/string/lower.rs | 46 ++++++--------- datafusion/functions/src/string/overlay.rs | 53 ++++++++--------- datafusion/functions/src/string/upper.rs | 47 ++++++--------- datafusion/functions/src/unicode/initcap.rs | 50 +++++++--------- 8 files changed, 178 insertions(+), 235 deletions(-) diff --git a/datafusion/functions/src/string/concat.rs b/datafusion/functions/src/string/concat.rs index f4848c131504..87ac979bc057 100644 --- a/datafusion/functions/src/string/concat.rs +++ b/datafusion/functions/src/string/concat.rs @@ -19,7 +19,7 @@ use arrow::array::{as_largestring_array, Array}; use arrow::datatypes::DataType; use datafusion_expr::sort_properties::ExprProperties; use std::any::Any; -use std::sync::{Arc, OnceLock}; +use std::sync::Arc; use crate::string::concat; use crate::strings::{ @@ -28,11 +28,30 @@ use crate::strings::{ use datafusion_common::cast::{as_string_array, as_string_view_array}; use datafusion_common::{internal_err, plan_err, Result, ScalarValue}; use datafusion_expr::expr::ScalarFunction; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::simplify::{ExprSimplifyResult, SimplifyInfo}; use datafusion_expr::{lit, ColumnarValue, Documentation, Expr, Volatility}; use datafusion_expr::{ScalarUDFImpl, Signature}; +use datafusion_macros::user_doc; +#[user_doc( + doc_section(label = "String Functions"), + description = "Concatenates multiple strings together.", + syntax_example = "concat(str[, ..., str_n])", + sql_example = r#"```sql +> select concat('data', 'f', 'us', 'ion'); ++-------------------------------------------------------+ +| concat(Utf8("data"),Utf8("f"),Utf8("us"),Utf8("ion")) | ++-------------------------------------------------------+ +| datafusion | ++-------------------------------------------------------+ +```"#, + standard_argument(name = "str", prefix = "String"), + argument( + name = "str_n", + description = "Subsequent string expressions to concatenate." + ), + related_udf(name = "concat_ws") +)] #[derive(Debug)] pub struct ConcatFunc { signature: Signature, @@ -264,7 +283,7 @@ impl ScalarUDFImpl for ConcatFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_concat_doc()) + self.doc() } fn preserves_lex_ordering(&self, _inputs: &[ExprProperties]) -> Result { @@ -272,32 +291,6 @@ impl ScalarUDFImpl for ConcatFunc { } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_concat_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Concatenates multiple strings together.", - "concat(str[, ..., str_n])", - ) - .with_sql_example( - r#"```sql -> select concat('data', 'f', 'us', 'ion'); -+-------------------------------------------------------+ -| concat(Utf8("data"),Utf8("f"),Utf8("us"),Utf8("ion")) | -+-------------------------------------------------------+ -| datafusion | -+-------------------------------------------------------+ -```"#, - ) - .with_standard_argument("str", Some("String")) - .with_argument("str_n", "Subsequent string expressions to concatenate.") - .with_related_udf("concat_ws") - .build() - }) -} - pub fn simplify_concat(args: Vec) -> Result { let mut new_args = Vec::with_capacity(args.len()); let mut contiguous_scalar = "".to_string(); diff --git a/datafusion/functions/src/string/concat_ws.rs b/datafusion/functions/src/string/concat_ws.rs index 7db8dbec4a71..df5eca3c4a05 100644 --- a/datafusion/functions/src/string/concat_ws.rs +++ b/datafusion/functions/src/string/concat_ws.rs @@ -17,7 +17,7 @@ use arrow::array::{as_largestring_array, Array, StringArray}; use std::any::Any; -use std::sync::{Arc, OnceLock}; +use std::sync::Arc; use arrow::datatypes::DataType; @@ -27,11 +27,34 @@ use crate::strings::{ColumnarValueRef, StringArrayBuilder}; use datafusion_common::cast::{as_string_array, as_string_view_array}; use datafusion_common::{exec_err, internal_err, plan_err, Result, ScalarValue}; use datafusion_expr::expr::ScalarFunction; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::simplify::{ExprSimplifyResult, SimplifyInfo}; use datafusion_expr::{lit, ColumnarValue, Documentation, Expr, Volatility}; use datafusion_expr::{ScalarUDFImpl, Signature}; +use datafusion_macros::user_doc; +#[user_doc( + doc_section(label = "String Functions"), + description = "Concatenates multiple strings together with a specified separator.", + syntax_example = "concat_ws(separator, str[, ..., str_n])", + sql_example = r#"```sql +> select concat_ws('_', 'data', 'fusion'); ++--------------------------------------------------+ +| concat_ws(Utf8("_"),Utf8("data"),Utf8("fusion")) | ++--------------------------------------------------+ +| data_fusion | ++--------------------------------------------------+ +```"#, + standard_argument(name = "str", prefix = "String"), + argument( + name = "separator", + description = "Separator to insert between concatenated strings." + ), + argument( + name = "str_n", + description = "Subsequent string expressions to concatenate." + ), + related_udf(name = "concat") +)] #[derive(Debug)] pub struct ConcatWsFunc { signature: Signature, @@ -271,40 +294,10 @@ impl ScalarUDFImpl for ConcatWsFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_concat_ws_doc()) + self.doc() } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_concat_ws_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Concatenates multiple strings together with a specified separator.", - "concat_ws(separator, str[, ..., str_n])", - ) - .with_sql_example( - r#"```sql -> select concat_ws('_', 'data', 'fusion'); -+--------------------------------------------------+ -| concat_ws(Utf8("_"),Utf8("data"),Utf8("fusion")) | -+--------------------------------------------------+ -| data_fusion | -+--------------------------------------------------+ -```"#, - ) - .with_argument( - "separator", - "Separator to insert between concatenated strings.", - ) - .with_standard_argument("str", Some("String")) - .with_argument("str_n", "Subsequent string expressions to concatenate.") - .with_related_udf("concat") - .build() - }) -} - fn simplify_concat_ws(delimiter: &Expr, args: &[Expr]) -> Result { match delimiter { Expr::Literal( diff --git a/datafusion/functions/src/string/ends_with.rs b/datafusion/functions/src/string/ends_with.rs index 1632fdd9943e..0a77ec9ebd2c 100644 --- a/datafusion/functions/src/string/ends_with.rs +++ b/datafusion/functions/src/string/ends_with.rs @@ -16,17 +16,38 @@ // under the License. use std::any::Any; -use std::sync::{Arc, OnceLock}; +use std::sync::Arc; use arrow::array::ArrayRef; use arrow::datatypes::DataType; use crate::utils::make_scalar_function; use datafusion_common::{internal_err, Result}; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::{ColumnarValue, Documentation, Volatility}; use datafusion_expr::{ScalarUDFImpl, Signature}; +use datafusion_macros::user_doc; +#[user_doc( + doc_section(label = "String Functions"), + description = "Tests if a string ends with a substring.", + syntax_example = "ends_with(str, substr)", + sql_example = r#"```sql +> select ends_with('datafusion', 'soin'); ++--------------------------------------------+ +| ends_with(Utf8("datafusion"),Utf8("soin")) | ++--------------------------------------------+ +| false | ++--------------------------------------------+ +> select ends_with('datafusion', 'sion'); ++--------------------------------------------+ +| ends_with(Utf8("datafusion"),Utf8("sion")) | ++--------------------------------------------+ +| true | ++--------------------------------------------+ +```"#, + standard_argument(name = "str", prefix = "String"), + argument(name = "substr", description = "Substring to test for.") +)] #[derive(Debug)] pub struct EndsWithFunc { signature: Signature, @@ -79,41 +100,10 @@ impl ScalarUDFImpl for EndsWithFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_ends_with_doc()) + self.doc() } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_ends_with_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Tests if a string ends with a substring.", - "ends_with(str, substr)", - ) - .with_sql_example( - r#"```sql -> select ends_with('datafusion', 'soin'); -+--------------------------------------------+ -| ends_with(Utf8("datafusion"),Utf8("soin")) | -+--------------------------------------------+ -| false | -+--------------------------------------------+ -> select ends_with('datafusion', 'sion'); -+--------------------------------------------+ -| ends_with(Utf8("datafusion"),Utf8("sion")) | -+--------------------------------------------+ -| true | -+--------------------------------------------+ -```"#, - ) - .with_standard_argument("str", Some("String")) - .with_argument("substr", "Substring to test for.") - .build() - }) -} - /// Returns true if string ends with suffix. /// ends_with('alphabet', 'abet') = 't' pub fn ends_with(args: &[ArrayRef]) -> Result { diff --git a/datafusion/functions/src/string/levenshtein.rs b/datafusion/functions/src/string/levenshtein.rs index 51ff428055e4..57392c114d79 100644 --- a/datafusion/functions/src/string/levenshtein.rs +++ b/datafusion/functions/src/string/levenshtein.rs @@ -16,7 +16,7 @@ // under the License. use std::any::Any; -use std::sync::{Arc, OnceLock}; +use std::sync::Arc; use arrow::array::{ArrayRef, Int32Array, Int64Array, OffsetSizeTrait}; use arrow::datatypes::DataType; @@ -25,10 +25,31 @@ use crate::utils::{make_scalar_function, utf8_to_int_type}; use datafusion_common::cast::{as_generic_string_array, as_string_view_array}; use datafusion_common::utils::datafusion_strsim; use datafusion_common::{exec_err, Result}; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::{ColumnarValue, Documentation}; use datafusion_expr::{ScalarUDFImpl, Signature, Volatility}; +use datafusion_macros::user_doc; +#[user_doc( + doc_section(label = "String Functions"), + description = "Returns the [`Levenshtein distance`](https://en.wikipedia.org/wiki/Levenshtein_distance) between the two given strings.", + syntax_example = "levenshtein(str1, str2)", + sql_example = r#"```sql +> select levenshtein('kitten', 'sitting'); ++---------------------------------------------+ +| levenshtein(Utf8("kitten"),Utf8("sitting")) | ++---------------------------------------------+ +| 3 | ++---------------------------------------------+ +```"#, + argument( + name = "str1", + description = "String expression to compute Levenshtein distance with str2." + ), + argument( + name = "str2", + description = "String expression to compute Levenshtein distance with str1." + ) +)] #[derive(Debug)] pub struct LevenshteinFunc { signature: Signature, @@ -82,32 +103,10 @@ impl ScalarUDFImpl for LevenshteinFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_levenshtein_doc()) + self.doc() } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_levenshtein_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Returns the [`Levenshtein distance`](https://en.wikipedia.org/wiki/Levenshtein_distance) between the two given strings.", - "levenshtein(str1, str2)") - .with_sql_example(r#"```sql -> select levenshtein('kitten', 'sitting'); -+---------------------------------------------+ -| levenshtein(Utf8("kitten"),Utf8("sitting")) | -+---------------------------------------------+ -| 3 | -+---------------------------------------------+ -```"#) - .with_argument("str1", "String expression to compute Levenshtein distance with str2.") - .with_argument("str2", "String expression to compute Levenshtein distance with str1.") - .build() - }) -} - ///Returns the Levenshtein distance between the two given strings. /// LEVENSHTEIN('kitten', 'sitting') = 3 pub fn levenshtein(args: &[ArrayRef]) -> Result { diff --git a/datafusion/functions/src/string/lower.rs b/datafusion/functions/src/string/lower.rs index 67c80cb785b6..e90c3804b1ee 100644 --- a/datafusion/functions/src/string/lower.rs +++ b/datafusion/functions/src/string/lower.rs @@ -17,15 +17,30 @@ use arrow::datatypes::DataType; use std::any::Any; -use std::sync::OnceLock; use crate::string::common::to_lower; use crate::utils::utf8_to_str_type; use datafusion_common::Result; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::{ColumnarValue, Documentation}; use datafusion_expr::{ScalarUDFImpl, Signature, Volatility}; +use datafusion_macros::user_doc; +#[user_doc( + doc_section(label = "String Functions"), + description = "Converts a string to lower-case.", + syntax_example = "lower(str)", + sql_example = r#"```sql +> select lower('Ångström'); ++-------------------------+ +| lower(Utf8("Ångström")) | ++-------------------------+ +| ångström | ++-------------------------+ +```"#, + standard_argument(name = "str", prefix = "String"), + related_udf(name = "initcap"), + related_udf(name = "upper") +)] #[derive(Debug)] pub struct LowerFunc { signature: Signature, @@ -71,35 +86,10 @@ impl ScalarUDFImpl for LowerFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_lower_doc()) + self.doc() } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_lower_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Converts a string to lower-case.", - "lower(str)", - ) - .with_sql_example( - r#"```sql -> select lower('Ångström'); -+-------------------------+ -| lower(Utf8("Ångström")) | -+-------------------------+ -| ångström | -+-------------------------+ -```"#, - ) - .with_standard_argument("str", Some("String")) - .with_related_udf("initcap") - .with_related_udf("upper") - .build() - }) -} #[cfg(test)] mod tests { use super::*; diff --git a/datafusion/functions/src/string/overlay.rs b/datafusion/functions/src/string/overlay.rs index ced263456802..3389da0968f7 100644 --- a/datafusion/functions/src/string/overlay.rs +++ b/datafusion/functions/src/string/overlay.rs @@ -16,7 +16,7 @@ // under the License. use std::any::Any; -use std::sync::{Arc, OnceLock}; +use std::sync::Arc; use arrow::array::{ArrayRef, GenericStringArray, OffsetSizeTrait}; use arrow::datatypes::DataType; @@ -26,10 +26,33 @@ use datafusion_common::cast::{ as_generic_string_array, as_int64_array, as_string_view_array, }; use datafusion_common::{exec_err, Result}; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::{ColumnarValue, Documentation, TypeSignature, Volatility}; use datafusion_expr::{ScalarUDFImpl, Signature}; +use datafusion_macros::user_doc; +#[user_doc( + doc_section(label = "String Functions"), + description = "Returns the string which is replaced by another string from the specified position and specified count length.", + syntax_example = "overlay(str PLACING substr FROM pos [FOR count])", + sql_example = r#"```sql +> select overlay('Txxxxas' placing 'hom' from 2 for 4); ++--------------------------------------------------------+ +| overlay(Utf8("Txxxxas"),Utf8("hom"),Int64(2),Int64(4)) | ++--------------------------------------------------------+ +| Thomas | ++--------------------------------------------------------+ +```"#, + standard_argument(name = "str", prefix = "String"), + argument(name = "substr", description = "Substring to replace in str."), + argument( + name = "pos", + description = "The start position to start the replace in str." + ), + argument( + name = "count", + description = "The count of characters to be replaced from start position of str. If not specified, will use substr length instead." + ) +)] #[derive(Debug)] pub struct OverlayFunc { signature: Signature, @@ -92,34 +115,10 @@ impl ScalarUDFImpl for OverlayFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_overlay_doc()) + self.doc() } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_overlay_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Returns the string which is replaced by another string from the specified position and specified count length.", - "overlay(str PLACING substr FROM pos [FOR count])") - .with_sql_example(r#"```sql -> select overlay('Txxxxas' placing 'hom' from 2 for 4); -+--------------------------------------------------------+ -| overlay(Utf8("Txxxxas"),Utf8("hom"),Int64(2),Int64(4)) | -+--------------------------------------------------------+ -| Thomas | -+--------------------------------------------------------+ -```"#) - .with_standard_argument("str", Some("String")) - .with_argument("substr", "Substring to replace in str.") - .with_argument("pos", "The start position to start the replace in str.") - .with_argument("count", "The count of characters to be replaced from start position of str. If not specified, will use substr length instead.") - .build() - }) -} - macro_rules! process_overlay { // For the three-argument case ($string_array:expr, $characters_array:expr, $pos_num:expr) => {{ diff --git a/datafusion/functions/src/string/upper.rs b/datafusion/functions/src/string/upper.rs index 1d05c42394a7..20b1c593f1eb 100644 --- a/datafusion/functions/src/string/upper.rs +++ b/datafusion/functions/src/string/upper.rs @@ -19,12 +19,27 @@ use crate::string::common::to_upper; use crate::utils::utf8_to_str_type; use arrow::datatypes::DataType; use datafusion_common::Result; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::{ColumnarValue, Documentation}; use datafusion_expr::{ScalarUDFImpl, Signature, Volatility}; +use datafusion_macros::user_doc; use std::any::Any; -use std::sync::OnceLock; +#[user_doc( + doc_section(label = "String Functions"), + description = "Converts a string to upper-case.", + syntax_example = "upper(str)", + sql_example = r#"```sql +> select upper('dataFusion'); ++---------------------------+ +| upper(Utf8("dataFusion")) | ++---------------------------+ +| DATAFUSION | ++---------------------------+ +```"#, + standard_argument(name = "str", prefix = "String"), + related_udf(name = "lower"), + related_udf(name = "initcap") +)] #[derive(Debug)] pub struct UpperFunc { signature: Signature, @@ -70,36 +85,10 @@ impl ScalarUDFImpl for UpperFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_upper_doc()) + self.doc() } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_upper_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Converts a string to upper-case.", - "upper(str)", - ) - .with_sql_example( - r#"```sql -> select upper('dataFusion'); -+---------------------------+ -| upper(Utf8("dataFusion")) | -+---------------------------+ -| DATAFUSION | -+---------------------------+ -```"#, - ) - .with_standard_argument("str", Some("String")) - .with_related_udf("initcap") - .with_related_udf("lower") - .build() - }) -} - #[cfg(test)] mod tests { use super::*; diff --git a/datafusion/functions/src/unicode/initcap.rs b/datafusion/functions/src/unicode/initcap.rs index c21fb77c9eca..03314bb24925 100644 --- a/datafusion/functions/src/unicode/initcap.rs +++ b/datafusion/functions/src/unicode/initcap.rs @@ -16,7 +16,7 @@ // under the License. use std::any::Any; -use std::sync::{Arc, OnceLock}; +use std::sync::Arc; use arrow::array::{ Array, ArrayRef, GenericStringBuilder, OffsetSizeTrait, StringViewBuilder, @@ -26,10 +26,27 @@ use arrow::datatypes::DataType; use crate::utils::{make_scalar_function, utf8_to_str_type}; use datafusion_common::cast::{as_generic_string_array, as_string_view_array}; use datafusion_common::{exec_err, Result}; -use datafusion_expr::scalar_doc_sections::DOC_SECTION_STRING; use datafusion_expr::{ColumnarValue, Documentation, Volatility}; use datafusion_expr::{ScalarUDFImpl, Signature}; +use datafusion_macros::user_doc; +#[user_doc( + doc_section(label = "String Functions"), + description = "Capitalizes the first character in each word in the input string. \ + Words are delimited by non-alphanumeric characters.", + syntax_example = "initcap(str)", + sql_example = r#"```sql +> select initcap('apache datafusion'); ++------------------------------------+ +| initcap(Utf8("apache datafusion")) | ++------------------------------------+ +| Apache Datafusion | ++------------------------------------+ +```"#, + standard_argument(name = "str", prefix = "String"), + related_udf(name = "lower"), + related_udf(name = "upper") +)] #[derive(Debug)] pub struct InitcapFunc { signature: Signature, @@ -86,37 +103,10 @@ impl ScalarUDFImpl for InitcapFunc { } fn documentation(&self) -> Option<&Documentation> { - Some(get_initcap_doc()) + self.doc() } } -static DOCUMENTATION: OnceLock = OnceLock::new(); - -fn get_initcap_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { - Documentation::builder( - DOC_SECTION_STRING, - "Capitalizes the first character in each word in the input string. \ - Words are delimited by non-alphanumeric characters.", - "initcap(str)", - ) - .with_sql_example( - r#"```sql -> select initcap('apache datafusion'); -+------------------------------------+ -| initcap(Utf8("apache datafusion")) | -+------------------------------------+ -| Apache Datafusion | -+------------------------------------+ -```"#, - ) - .with_standard_argument("str", Some("String")) - .with_related_udf("lower") - .with_related_udf("upper") - .build() - }) -} - /// Converts 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. From 7cfed4b07058c5b46ca6dac052523b023dfe2adc Mon Sep 17 00:00:00 2001 From: Cheng-Yuan-Lai Date: Sun, 29 Dec 2024 21:48:32 +0800 Subject: [PATCH 2/7] doc-gen: update function docs --- docs/source/user-guide/sql/scalar_functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md index ac0978683c36..c69f26baf75a 100644 --- a/docs/source/user-guide/sql/scalar_functions.md +++ b/docs/source/user-guide/sql/scalar_functions.md @@ -971,8 +971,8 @@ concat_ws(separator, str[, ..., str_n]) #### Arguments -- **separator**: Separator to insert between concatenated strings. - **str**: String expression to operate on. Can be a constant, column, or function, and any combination of operators. +- **separator**: Separator to insert between concatenated strings. - **str_n**: Subsequent string expressions to concatenate. #### Example @@ -1697,8 +1697,8 @@ upper(str) **Related functions**: -- [initcap](#initcap) - [lower](#lower) +- [initcap](#initcap) ### `uuid` From f713c7a4bcf632209dc1a383904553bebc9a1fe7 Mon Sep 17 00:00:00 2001 From: Cheng-Yuan-Lai Date: Mon, 30 Dec 2024 21:11:29 +0800 Subject: [PATCH 3/7] doc: fix related udf order for upper function in documentation --- datafusion/functions/src/string/upper.rs | 4 ++-- docs/source/user-guide/sql/scalar_functions.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/datafusion/functions/src/string/upper.rs b/datafusion/functions/src/string/upper.rs index 20b1c593f1eb..7bab33e68a4d 100644 --- a/datafusion/functions/src/string/upper.rs +++ b/datafusion/functions/src/string/upper.rs @@ -37,8 +37,8 @@ use std::any::Any; +---------------------------+ ```"#, standard_argument(name = "str", prefix = "String"), - related_udf(name = "lower"), - related_udf(name = "initcap") + related_udf(name = "initcap"), + related_udf(name = "lower") )] #[derive(Debug)] pub struct UpperFunc { diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md index c69f26baf75a..ac59a418935d 100644 --- a/docs/source/user-guide/sql/scalar_functions.md +++ b/docs/source/user-guide/sql/scalar_functions.md @@ -1697,8 +1697,8 @@ upper(str) **Related functions**: -- [lower](#lower) - [initcap](#initcap) +- [lower](#lower) ### `uuid` From 1a459122905d42a090da897b9441e5983f7657d8 Mon Sep 17 00:00:00 2001 From: Oleks V Date: Thu, 2 Jan 2025 11:17:11 -0800 Subject: [PATCH 4/7] Update datafusion/functions/src/string/concat_ws.rs --- datafusion/functions/src/string/concat_ws.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/datafusion/functions/src/string/concat_ws.rs b/datafusion/functions/src/string/concat_ws.rs index df5eca3c4a05..90e86afa01de 100644 --- a/datafusion/functions/src/string/concat_ws.rs +++ b/datafusion/functions/src/string/concat_ws.rs @@ -44,11 +44,13 @@ use datafusion_macros::user_doc; | data_fusion | +--------------------------------------------------+ ```"#, - standard_argument(name = "str", prefix = "String"), argument( name = "separator", description = "Separator to insert between concatenated strings." ), + argument( + name = "str", + description = "String expression to operate on. Can be a constant, column, or function, and any combination of operators."), argument( name = "str_n", description = "Subsequent string expressions to concatenate." From deb6c5d6045bd3c160cda677652b4783b8b6579c Mon Sep 17 00:00:00 2001 From: Oleks V Date: Thu, 2 Jan 2025 11:20:58 -0800 Subject: [PATCH 5/7] Update datafusion/functions/src/string/concat_ws.rs --- datafusion/functions/src/string/concat_ws.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/datafusion/functions/src/string/concat_ws.rs b/datafusion/functions/src/string/concat_ws.rs index 90e86afa01de..663e7e4db70b 100644 --- a/datafusion/functions/src/string/concat_ws.rs +++ b/datafusion/functions/src/string/concat_ws.rs @@ -44,13 +44,14 @@ use datafusion_macros::user_doc; | data_fusion | +--------------------------------------------------+ ```"#, - argument( + argument( name = "separator", description = "Separator to insert between concatenated strings." ), argument( - name = "str", - description = "String expression to operate on. Can be a constant, column, or function, and any combination of operators."), + name = "str", + description = "String expression to operate on. Can be a constant, column, or function, and any combination of operators." + ), argument( name = "str_n", description = "Subsequent string expressions to concatenate." From f2318e5daac713ef4cce93f5a3863dae761d0fd3 Mon Sep 17 00:00:00 2001 From: Oleks V Date: Thu, 2 Jan 2025 11:24:43 -0800 Subject: [PATCH 6/7] Update datafusion/functions/src/string/concat_ws.rs --- datafusion/functions/src/string/concat_ws.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datafusion/functions/src/string/concat_ws.rs b/datafusion/functions/src/string/concat_ws.rs index 663e7e4db70b..821bb48a8ce2 100644 --- a/datafusion/functions/src/string/concat_ws.rs +++ b/datafusion/functions/src/string/concat_ws.rs @@ -44,7 +44,7 @@ use datafusion_macros::user_doc; | data_fusion | +--------------------------------------------------+ ```"#, - argument( + argument( name = "separator", description = "Separator to insert between concatenated strings." ), From 8c037ad029d31487e2ccf25f3b4859be9f7532c0 Mon Sep 17 00:00:00 2001 From: Cheng-Yuan Lai Date: Fri, 3 Jan 2025 10:31:44 +0800 Subject: [PATCH 7/7] doc-gen: update function docs --- docs/source/user-guide/sql/scalar_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md index ac59a418935d..ac0978683c36 100644 --- a/docs/source/user-guide/sql/scalar_functions.md +++ b/docs/source/user-guide/sql/scalar_functions.md @@ -971,8 +971,8 @@ concat_ws(separator, str[, ..., str_n]) #### Arguments -- **str**: String expression to operate on. Can be a constant, column, or function, and any combination of operators. - **separator**: Separator to insert between concatenated strings. +- **str**: String expression to operate on. Can be a constant, column, or function, and any combination of operators. - **str_n**: Subsequent string expressions to concatenate. #### Example