Uh oh!
There was an error while loading. Please reload this page.
Python: Optimize PyArrow reads - #6673
Merged
Merged
Conversation
PyArrow is still sluggish when it comes into opening files, and we
still see many requests being made to S3.
This PR removes the Dataset, and uses the lower read_table API.
Since the read_table API requires to pass in filters in the DNF
form, we need to do some additional conversion.
This PR reduces the number of calls from 203 to 165 on my test
query:
```python
from pyiceberg.catalog import load_catalog
catalog = load_catalog('local')
tbl = catalog.load_table('nyc.taxis')
from pyiceberg.expressions import GreaterThanOrEqual, LessThanOrEqual, And
sc = tbl.scan(row_filter=And(
GreaterThanOrEqual("tpep_pickup_datetime", "2022-04-01T00:00:00.000000+00:00"),
LessThanOrEqual("tpep_pickup_datetime", "2022-04-28T00:00:00.000000+00:00"),
)).to_arrow()
```
Also, clock time is lower:
```python
➜ iceberg git:(fd-optimize-pyarrow) ✗ time python3 /tmp/vo.py
python3 /tmp/vo.py 2.38s user 2.75s system 31% cpu 16.067 total
python3 /tmp/vo.py 2.55s user 2.57s system 36% cpu 14.097 total
python3 /tmp/vo.py 2.60s user 2.57s system 32% cpu 15.954 total
```
```python
➜ iceberg git:(master) time python3 /tmp/vo.py
python3 /tmp/vo.py 2.54s user 2.71s system 28% cpu 18.499 total
python3 /tmp/vo.py 2.75s user 2.56s system 24% cpu 21.547 total
python3 /tmp/vo.py 2.75s user 2.95s system 17% cpu 32.554 total
```
Keep in mind that these request are across the great oceanrdblue
reviewed
Jan 27, 2023
| raise ValueError(f"Missing Iceberg schema in Metadata for file: {path}") | ||
| arrow_table = pq.read_table( | ||
| source=fout, |
rdblue
approved these changes
Jan 27, 2023
rdblue
commented
Jan 27, 2023
Contributor
Looks good to me when tests are passing! |
Fokko
commented
Jan 27, 2023
ContributorAuthor
rdblue
reviewed
Jan 31, 2023
| def expression_to_plain_format(expressions: Tuple[BooleanExpression, ...]) -> List[List[Tuple[str, str, Any]]]: | ||
| def expression_to_plain_format( | ||
| expressions: Tuple[BooleanExpression, ...], cast_int_to_datetime: bool = False |
rdblue
approved these changes
Jan 31, 2023
rdblue
commented
Jan 31, 2023
Contributor
Thanks, @Fokko! Nice work. |
krvikash pushed a commit
to krvikash/iceberg
that referenced
this pull request
Mar 16, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PyArrow is still sluggish when it comes into opening files, and we still see many requests being made to S3.
This PR removes the Dataset, and uses the lower read_table API. Since the read_table API requires to pass in filters in the DNF form, we need to do some additional conversion.
This PR reduces the number of calls from 203 to 165. Requests log:
Before: https://gist.github.com/Fokko/96b4d5b65ec85c95d6e875f6ec19bf50
After: https://gist.github.com/Fokko/282f6b803d83a830465d97f64cf10057
Query used:
Logs:
Also, the wall clock time is lower:
Keep in mind that these requests are across the great ocean.