-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
-
Related to doc-gen: Migrate builtin scalar functions from code based documentation to attribute based #13671
@comphead I found that `user_doc()` only supports one alternative syntax. Should we modify it to support multiple alternative syntaxes?
Originally posted by @Chen-Yuan-Lai in #13924 (comment)
The idea is to migrate the trim function to use the doc macros
However, when @Chen-Yuan-Lai tried to do so in #13924 we found that the second alternative_syntax was ignored
Here is the rust change:
#[user_doc(
doc_section(label = "String Functions"),
description = "Trims the specified trim string from the start and end of a string. If no trim string is provided, all whitespace is removed from the start and end of the input string.",
syntax_example = "btrim(str[, trim_str])",
alternative_syntax = "trim(BOTH trim_str FROM str)",
alternative_syntax = "trim(trim_str FROM str)",
sql_example = r#"```sql
> select btrim('__datafusion____', '_');
+-------------------------------------------+
| btrim(Utf8("__datafusion____"),Utf8("_")) |
+-------------------------------------------+
| datafusion |
+-------------------------------------------+
```"#,
standard_argument(name = "str", prefix = "String"),
argument(
name = "trim_str",
description = "String expression to operate on. Can be a constant, column, or function, and any combination of operators. _Default is whitespace characters._"
),
related_udf(name = "ltrim"),
related_udf(name = "rtrim")
)]
#[derive(Debug)]
pub struct BTrimFunc {
signature: Signature,Then regenerate the documentation:
./dev/update_function_docs.shAnd you'll see that the second syntax is gone
#### Alternative Syntax
-```sql
-trim(BOTH trim_str FROM str)
-```
```sql
trim(trim_str FROM str)comphead and Chen-Yuan-Lai
Metadata
Metadata
Assignees
Labels
No labels