-
Notifications
You must be signed in to change notification settings - Fork 109
feat: add user defined table function support #1113
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
base: main
Are you sure you want to change the base?
feat: add user defined table function support #1113
Conversation
…er more examples than just table providers
…er and table function
2b7de60
to
a55969c
Compare
@mesejo @kosiew @chenkovsky @kevinjqliu Would any of you mind doing a review? We haven't released datafusion-python in a while and this is one of the PRs waiting to go in. 2/3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks good to me.
I left a minor comment and one more regarding a missing _create_table_udf_decorator function.
arrow = { version = "55" } | ||
arrow-array = { version = "55" } | ||
arrow-schema = { version = "55" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’ve pinned arrow = { version = "55" }, but other examples use arrow = { version = "55.0.0" }?
Should it be 55.*?
if args and hasattr(args[0], "__datafusion_table_function__"): | ||
return TableFunction(args[1], args[0]) | ||
# Case 2: Used as a decorator with parameters | ||
return TableFunction._create_table_udf_decorator(*args, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could not find _create_table_udf_decorator
in TableFunction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kosiew Thank you! Added!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Which issue does this PR close?
This addresses part of #1017
Rationale for this change
This feature exposes the ability to create user defined functions. Support exists in the upstream
datafusion
repository but was not exposed in the Python bindings.What changes are included in this PR?
This adds a new
udtf
function and associated classes for creating user defined table functions. With this change you can either provide a pure python or a rust backed udtf.There are new unit tests provided with this PR and an example usage.
Are there any user-facing changes?
This is a pure addition.