-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add a ScalarUDFImpl::simplfy() API #9289
Comments
FYI @jayzhan211 -- I wonder if you have any thoughts about this ticket (or maybe have time to try implementing it). I think a good test case would be to implement a udf function such as |
cc @universalmind303 and @thinkharderdev as I think you have been thinking about similar things |
In this case, should we add a function-level optimizer trying to rewrite the function? I think it would be a large match expression. I have done a similar issue today #9213 . Maybe I could do parts of it. |
Yes, @Lordworms I think that is an excellent idea. cc @mustafasrepo for your thoughts Note that #9213 is for an aggregate function, which I think would have a similar API though it would be on a different struct ( |
I think, function level optimizer would be much more scalable. Also, simplification logic will be more contained. Also, once we can bring similar changes in |
@jayzhan211 -- I think this proposal is also likely to be needed to get |
@alamb How is |
simplify for |
🤔 that is a good point that the simplification is needed for
Yes Sorry for my delay, I have been out the last few days. I am catching up with reviews |
Is your feature request related to a problem or challenge?
As part of porting
arrow_cast
#9287 andmake_array
#9288, it has become clear that some functions have special simplification semantics:arrow_cast
simplifies tocast
of a particular data type. It is important for the rest of datafusion to understand theCast
semantics as the there are several special cases for Expr::Cast (such asunwrap_cast_in_comparison
)make_array
has special rewrite rules to combine / fold witharray_append
andarray_prepaend
in the simplifier (source link)Also I think some systems may want to provide the ability to define UDFs that are more like macros (can be expressed in terms of other built in expressions), which needs some way for datafusion to "inline" the definition
Similarly, specialized functions (e.g replace
regexp_match
with a version that had the regexp pre-compiled ...) - #8051 sound very similarDescribe the solution you'd like
I propose adding a function such as the following, we could implement the simplifications for
make_array
andarrow_cast
in the UDF (and not in the main simplify code):}
Describe alternatives you've considered
There may be better
Additional context
No response
The text was updated successfully, but these errors were encountered: