-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
python: update docs to use new APIs #1287
Conversation
python/datafusion/__init__.py
Outdated
@@ -36,6 +38,7 @@ | |||
"ScalarUDF", | |||
"column", | |||
"literal", | |||
"functions", |
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.
this is the fix
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.
Actually this should be done by importing the functions submodule:
import datafusion
import datafusion.functions
datafusion.functions.abs(datafusion.column("a"))
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.
This is how the compute functions are exposed in pyarrow as well:
>>> import pyarrow
>>> pyarrow.compute.cast
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kszucs/.conda/envs/ibis39/lib/python3.9/site-packages/pyarrow/__init__.py", line 266, in __getattr__
raise AttributeError(
AttributeError: module 'pyarrow' has no attribute 'compute'
>>> import pyarrow.compute
>>> pyarrow.compute.cast
<function cast at 0x109349160>
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.
yeah, importing datafusion.functions
works as expected currently, this change is to make the code in our python doc work again: https://arrow.apache.org/datafusion/python/index.html#how-to-use-it. @kszucs is there any downside in making f = datafusion.functions
work on top of import datafusion.functions as f
?
Not really, it just feels odd for me. If we want to expose the functions as a module then I would stick with If we want to remain backward compatible then we can re-export the I don't have a strong opinion, so feel free to merge this PR as is - we can discuss it further after the release. |
python/datafusion/__init__.py
Outdated
@@ -36,6 +38,7 @@ | |||
"ScalarUDF", | |||
"column", | |||
"literal", | |||
"functions", |
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.
This is how the compute functions are exposed in pyarrow as well:
>>> import pyarrow
>>> pyarrow.compute.cast
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/kszucs/.conda/envs/ibis39/lib/python3.9/site-packages/pyarrow/__init__.py", line 266, in __getattr__
raise AttributeError(
AttributeError: module 'pyarrow' has no attribute 'compute'
>>> import pyarrow.compute
>>> pyarrow.compute.cast
<function cast at 0x109349160>
also implement __str__ for PyExpr and updated docs
@kszucs I pushed an update to keep the behavior consistent with pyarrow and updated the user doc to use the new api. Can you take another look? |
A bit late, but LGTM. Thanks @houqp! |
Thank you @kszucs for the epic refactor. Time to release it to pypi :) |
also implement __str__ for PyExpr and updated docs
Rationale for this change
The example in our python user doc is not working with the latest binding implementation. Found this while validating #1253
What changes are included in this PR?
__str__
for PyExprAre there any user-facing changes?
NO