diff --git a/datafusion/functions/src/datetime/date_part.rs b/datafusion/functions/src/datetime/date_part.rs index 3fefa5051376..01e094bc4e0b 100644 --- a/datafusion/functions/src/datetime/date_part.rs +++ b/datafusion/functions/src/datetime/date_part.rs @@ -255,6 +255,7 @@ fn get_date_part_doc() -> &'static Documentation { "expression", "Time expression to operate on. Can be a constant, column, or function.", ) + .with_alternative_syntax("extract(field FROM source)") .build() .unwrap() }) diff --git a/datafusion/functions/src/string/btrim.rs b/datafusion/functions/src/string/btrim.rs index f689f27d9d24..e215b18d9c3c 100644 --- a/datafusion/functions/src/string/btrim.rs +++ b/datafusion/functions/src/string/btrim.rs @@ -124,6 +124,8 @@ fn get_btrim_doc() -> &'static Documentation { ```"#) .with_standard_argument("str", Some("String")) .with_argument("trim_str", "String expression to operate on. Can be a constant, column, or function, and any combination of operators. _Default is whitespace characters._") + .with_alternative_syntax("trim(BOTH trim_str FROM str)") + .with_alternative_syntax("trim(trim_str FROM str)") .with_related_udf("ltrim") .with_related_udf("rtrim") .build() diff --git a/datafusion/functions/src/string/ltrim.rs b/datafusion/functions/src/string/ltrim.rs index 91809d691647..0b4c197646b6 100644 --- a/datafusion/functions/src/string/ltrim.rs +++ b/datafusion/functions/src/string/ltrim.rs @@ -124,6 +124,7 @@ fn get_ltrim_doc() -> &'static Documentation { ```"#) .with_standard_argument("str", Some("String")) .with_argument("trim_str", "String expression to trim from the beginning of the input string. Can be a constant, column, or function, and any combination of arithmetic operators. _Default is whitespace characters._") + .with_alternative_syntax("trim(LEADING trim_str FROM str)") .with_related_udf("btrim") .with_related_udf("rtrim") .build() diff --git a/datafusion/functions/src/string/rtrim.rs b/datafusion/functions/src/string/rtrim.rs index 06c8a85c38dd..e934147efbbe 100644 --- a/datafusion/functions/src/string/rtrim.rs +++ b/datafusion/functions/src/string/rtrim.rs @@ -124,6 +124,7 @@ fn get_rtrim_doc() -> &'static Documentation { ```"#) .with_standard_argument("str", Some("String")) .with_argument("trim_str", "String expression to trim from the end of the input string. Can be a constant, column, or function, and any combination of arithmetic operators. _Default is whitespace characters._") + .with_alternative_syntax("trim(TRAILING trim_str FROM str)") .with_related_udf("btrim") .with_related_udf("ltrim") .build() diff --git a/datafusion/functions/src/unicode/substr.rs b/datafusion/functions/src/unicode/substr.rs index 5a8c2500900b..edfe57210b71 100644 --- a/datafusion/functions/src/unicode/substr.rs +++ b/datafusion/functions/src/unicode/substr.rs @@ -173,6 +173,7 @@ fn get_substr_doc() -> &'static Documentation { .with_standard_argument("str", Some("String")) .with_argument("start_pos", "Character position to start the substring at. The first character in the string has a position of 1.") .with_argument("length", "Number of characters to extract. If not specified, returns the rest of the string after the start position.") + .with_alternative_syntax("substring(str from start_pos for length)") .build() .unwrap() }) diff --git a/docs/source/user-guide/sql/scalar_functions_new.md b/docs/source/user-guide/sql/scalar_functions_new.md index 6031a68d40e4..56173b97b405 100644 --- a/docs/source/user-guide/sql/scalar_functions_new.md +++ b/docs/source/user-guide/sql/scalar_functions_new.md @@ -808,6 +808,16 @@ btrim(str[, trim_str]) +-------------------------------------------+ ``` +#### Alternative Syntax + +```sql +trim(BOTH trim_str FROM str) +``` + +```sql +trim(trim_str FROM str) +``` + #### Aliases - trim @@ -1191,6 +1201,12 @@ ltrim(str[, trim_str]) +-------------------------------------------+ ``` +#### Alternative Syntax + +```sql +trim(LEADING trim_str FROM str) +``` + **Related functions**: - [btrim](#btrim) @@ -1387,6 +1403,12 @@ rtrim(str[, trim_str]) +-------------------------------------------+ ``` +#### Alternative Syntax + +```sql +trim(TRAILING trim_str FROM str) +``` + **Related functions**: - [btrim](#btrim) @@ -1501,6 +1523,12 @@ substr(str, start_pos[, length]) +----------------------------------------------+ ``` +#### Alternative Syntax + +```sql +substring(str from start_pos for length) +``` + #### Aliases - substring @@ -1965,6 +1993,12 @@ date_part(part, expression) - **expression**: Time expression to operate on. Can be a constant, column, or function. +#### Alternative Syntax + +```sql +extract(field FROM source) +``` + #### Aliases - datepart