Comments (7)
There's one distinction I didn't appreciate before: the current filter
argument is a row filter. But file_uris
is expecting a partition filter. It's OK to pass a row filter to a partition filter, but it's not OK to try to pass a partition filter if the dataset isn't actually partitioned on that expression.
I'm going to try briefly to see if we can automatically infer what subset of filter
to pass to partition_filters
. If I can't get that working, then maybe we add another keyword, partition_filter
, to handle that.
from dask-deltatable.
@TomAugspurger - here's the syntax for filtering the partitions and by the column file statistics:
import pyarrow as pa
import pyarrow.dataset as ds
from deltalake import DeltaTable, write_deltalake
sample_data = pa.table({
'part': pa.array(['a', 'a', 'b', 'b', 'c', 'c']),
'x': pa.array([1, 1, 2, 2, 3, 3])
})
write_deltalake('sample_data', sample_data, partition_by=['part'])
dt = DeltaTable('sample_data')
dt.file_uris(partition_filters=[('part', '>', 'a')])
# ['/Users/willjones/Documents/notebooks/sample_data/part=c/0-acc806b2-a96d-47cc-ac80-7607abca0a66-0.parquet',
# '/Users/willjones/Documents/notebooks/sample_data/part=b/0-acc806b2-a96d-47cc-ac80-7607abca0a66-0.parquet']
# With Dataset.get_fragments
filter = (ds.field('part') > 'a') & (ds.field('x') < 3)
fragments = dt.to_pyarrow_dataset().get_fragments(filter=filter)
list(fragment.path for fragment in fragments)
# ['part=b/0-acc806b2-a96d-47cc-ac80-7607abca0a66-0.parquet']
Courtesy of @wjones127 in this issue.
from dask-deltatable.
Apparently passing a filter to file_uris
is somewhat new in deltalake
. I didn't find a changelog, but it is present in 0.8.1.
from dask-deltatable.
Wow, This looks like a Massive improvement! Thanks a lot for this detailed analysis and suggestion! Happy to help wherever I can!
from dask-deltatable.
- Makes Complete Sense, Actually I am also inclined towards having paritition_filter and filer_uris as separate Keyword arguments to the function. let me know your thoughts here!
from dask-deltatable.
I recently created a delta-rs issue to add a filters
argument to file_uris()
that will behave as expected.
from dask-deltatable.
As an end user I would hope to not have to care about the difference between partition_filter
and filter
.
How about a read_delta
API that is only accepting filter
and in the background it splits the partition vs file filters itself.
In @MrPowers example this would look like
ddf = read_delta(
'sample_data',
filters=[
('part', '>', 'a'),
('x', '<', '3'),
]
)
assert ddf.npartitions == 1
Is there any reason why this should not be the top-level API?
from dask-deltatable.
Related Issues (20)
- Handle timestamps other than `datetime64[us]`
- Release soon? HOT 5
- Finalize API for writing Delta Tables HOT 1
- Support pyarrow types_mapper kwarg
- Pickle error with `ParquetFileWriteOptions` and `distributed.Client`
- Support reading and writing to remote filesystems (s3, gcsfs, azure)
- Credentials for remote filesystems?
- `storage_options` inconsistency between `read_deltalake` and `to_deltalake`
- `TypeError`: cannot pickle `builtins.RawDeltaTable` object
- `read_deltalake` vs `read_parquet` performance HOT 1
- Can we get rid of `filters_to_expression`?
- What are the limitations of to_deltalake? HOT 1
- Problem with `pyarrow` dependency when installing dask-deltatable HOT 3
- Failed import when running `deltalake==0.14.0` HOT 4
- Order data by partitions if available HOT 3
- Specify AWS Permissions if reading from S3 HOT 1
- Overwriting tables
- `ImportError` with `deltalake=0.16.0` HOT 4
- Example in Readme not reproducible HOT 2
- `read_deltalake` breaks with dask>=2024.3.1 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dask-deltatable.