-
Notifications
You must be signed in to change notification settings - Fork 180
fix: Disallow lazy backend in read_parquet
#2980
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -591,20 +591,33 @@ def read_csv( | |
| | 1 2 5 | | ||
| ββββββββββββββββββββ | ||
| """ | ||
| eager_backend = Implementation.from_backend(backend) | ||
| native_namespace = eager_backend.to_native_namespace() | ||
| impl = Implementation.from_backend(backend) | ||
| native_namespace = impl.to_native_namespace() | ||
| native_frame: NativeFrame | ||
| if eager_backend in { | ||
| if impl in { | ||
| Implementation.POLARS, | ||
| Implementation.PANDAS, | ||
| Implementation.MODIN, | ||
| Implementation.CUDF, | ||
| }: | ||
| native_frame = native_namespace.read_csv(source, **kwargs) | ||
| elif eager_backend is Implementation.PYARROW: | ||
| elif impl is Implementation.PYARROW: | ||
| from pyarrow import csv # ignore-banned-import | ||
|
|
||
| native_frame = csv.read_csv(source, **kwargs) | ||
| elif impl in { | ||
| Implementation.PYSPARK, | ||
| Implementation.DASK, | ||
| Implementation.DUCKDB, | ||
| Implementation.IBIS, | ||
| Implementation.SQLFRAME, | ||
| Implementation.PYSPARK_CONNECT, | ||
| }: | ||
| msg = ( | ||
| f"Expected eager backend, found {impl}.\n\n" | ||
| f"Hint: use nw.scan_csv(source={source}, backend={backend})" | ||
| ) | ||
| raise ValueError(msg) | ||
| else: # pragma: no cover | ||
| try: | ||
| # implementation is UNKNOWN, Narwhals extension using this feature should | ||
|
|
@@ -734,22 +747,33 @@ def read_parquet( | |
| |c: [[0.2,0.1]] | | ||
| ββββββββββββββββββββ | ||
| """ | ||
| implementation = Implementation.from_backend(backend) | ||
| native_namespace = implementation.to_native_namespace() | ||
| impl = Implementation.from_backend(backend) | ||
| native_namespace = impl.to_native_namespace() | ||
| native_frame: NativeFrame | ||
| if implementation in { | ||
| if impl in { | ||
| Implementation.POLARS, | ||
| Implementation.PANDAS, | ||
| Implementation.MODIN, | ||
| Implementation.CUDF, | ||
| Implementation.DUCKDB, | ||
| Implementation.IBIS, | ||
|
Comment on lines
-745
to
-746
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it possible these were supposed to be supported for They stand out as the impls that had an interchange support for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thaaaat's totally possible! However I find it weird that:
π€
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah true, I guess you could investigate π§ the blame?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #1725 introduced full support for duckdb, and added duckdb in These are way after interchange protocol support, so it seems completely accidental, and we just missed it. Both PRs were 2k+ lines changes and we had no test to prevent that |
||
| }: | ||
| native_frame = native_namespace.read_parquet(source, **kwargs) | ||
| elif implementation is Implementation.PYARROW: | ||
| elif impl is Implementation.PYARROW: | ||
| import pyarrow.parquet as pq # ignore-banned-import | ||
|
|
||
| native_frame = pq.read_table(source, **kwargs) | ||
| elif impl in { | ||
| Implementation.PYSPARK, | ||
| Implementation.DASK, | ||
| Implementation.DUCKDB, | ||
| Implementation.IBIS, | ||
| Implementation.SQLFRAME, | ||
| Implementation.PYSPARK_CONNECT, | ||
| }: | ||
| msg = ( | ||
| f"Expected eager backend, found {impl}.\n\n" | ||
| f"Hint: use nw.scan_parquet(source={source}, backend={backend})" | ||
| ) | ||
| raise ValueError(msg) | ||
| else: # pragma: no cover | ||
| try: | ||
| # implementation is UNKNOWN, Narwhals extension using this feature should | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
For
read_csvI simply wanted to improve on the error message