alamb commented on code in PR #10321:
URL: https://github.com/apache/datafusion/pull/10321#discussion_r1586856895
##########
datafusion/functions/src/core/mod.rs:
##########
@@ -39,14 +42,68 @@ make_udf_function!(getfield::GetFieldFunc, GET_FIELD,
get_field);
make_udf_function!(coalesce::CoalesceFunc, COALESCE, coalesce);
// Export the functions out of this package, both as expr_fn as well as a list
of functions
-export_functions!(
- (nullif, arg_1 arg_2, "returns NULL if value1 equals value2; otherwise it
returns value1. This can be used to perform the inverse operation of the
COALESCE expression."),
- (arrow_cast, arg_1 arg_2, "returns arg_1 cast to the `arrow_type` given
the second argument. This can be used to cast to a specific `arrow_type`."),
- (nvl, arg_1 arg_2, "returns value2 if value1 is NULL; otherwise it returns
value1"),
- (nvl2, arg_1 arg_2 arg_3, "Returns value2 if value1 is not NULL;
otherwise, it returns value3."),
- (arrow_typeof, arg_1, "Returns the Arrow type of the input expression."),
- (r#struct, args, "Returns a struct with the given arguments"),
- (named_struct, args, "Returns a struct with the given names and arguments
pairs"),
- (get_field, arg_1 arg_2, "Returns the value of the field with the given
name from the struct"),
- (coalesce, args, "Returns `coalesce(args...)`, which evaluates to the
value of the first expr which is not NULL")
-);
+pub mod expr_fn {
Review Comment:
What I could't figure out how to do was make the macro take both syntaxes
It would have to look something like
```rust
export_functions!(
// create a function with arg_1 and arg_2 Expr arguments
(arrow_cast, arg_1 arg_2, "returns arg_1 cast to the `arrow_type` given
the second argument. This can be used to cast to a specific `arrow_type`."),
/// create a function with a single Vec<Expr> arg
(coalesce, args, "Returns `coalesce(args...)`, which evaluates to the
value of the first expr which is not NULL")
...
}
```
the macro definition is
https://github.com/apache/datafusion/blob/7c1c7941a078153173a6c82bf2c8742bbcbdefa8/datafusion/functions/src/macros.rs#L39-L60
there may be some way to do this in rust, but I could't figure it out
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]