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

Reduce repetition in datafusion::functions using macros #10397

Closed
alamb opened this issue May 6, 2024 · 1 comment · Fixed by #10700
Closed

Reduce repetition in datafusion::functions using macros #10397

alamb opened this issue May 6, 2024 · 1 comment · Fixed by #10700

Comments

@alamb
Copy link
Contributor

alamb commented May 6, 2024

          I think it is possible to take `Vec` like what functions-array macro does
($UDF:ty, $EXPR_FN:ident, $DOC:expr , $SCALAR_UDF_FN:ident) => {
        paste::paste! {
            // "fluent expr_fn" style function
            #[doc = $DOC]
            pub fn $EXPR_FN(arg: Vec<Expr>) -> Expr {
                Expr::ScalarFunction(ScalarFunction::new_udf(
                    $SCALAR_UDF_FN(),
                    arg,
                ))
            }

Originally posted by @jayzhan211 in #10321 (comment)

@alamb
Copy link
Contributor Author

alamb commented May 6, 2024

Specifically, I think @jayzhan211 found a nice solution on the rust forums:

https://users.rust-lang.org/t/macro-repetition-with-multiple-rules/110816/2?u=jayzhan

I got a probably better solution (I had not tried it) from rust forum. To anyone that is interested in

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

Successfully merging a pull request may close this issue.

1 participant