Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the user_doc() macro to support multiple alternative syntaxes #13944

Closed
alamb opened this issue Dec 30, 2024 · 1 comment · Fixed by #13952
Closed

Update the user_doc() macro to support multiple alternative syntaxes #13944

alamb opened this issue Dec 30, 2024 · 1 comment · Fixed by #13952
Assignees

Comments

@alamb
Copy link
Contributor

alamb commented Dec 30, 2024

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.sh

And you'll see that the second syntax is gone

#### Alternative Syntax

-```sql
-trim(BOTH trim_str FROM str)
-```

```sql
trim(trim_str FROM str)
@alamb alamb changed the title @comphead I found that use_doc() only supports one alternative syntax. Should we modify it to support multiple alternative syntaxes? Update the user_doc() macro to support multiple alternative syntaxes Dec 30, 2024
@delamarch3
Copy link
Contributor

take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants