-
Notifications
You must be signed in to change notification settings - Fork 233
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
PyArrow: Avoid buffer-overflow by avoid doing a sort #1555
Merged
Merged
Changes from 5 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1b29d06
PyArrow: Avoid buffer-overflow by avoid doing a sort
Fokko cafd39d
Thanks Kevin!
Fokko 7442c41
lint
Fokko 3c590cb
Remove int column
Fokko e40e826
Merge branch 'main' of github.com:apache/iceberg-python into fd-fix-o…
Fokko 93a6522
Update NOTICE copyright to 2025 (#1557)
kevinjqliu 23dd64e
WIP
Fokko aae860f
Merge branch 'main' of github.com:apache/iceberg-python into fd-fix-o…
Fokko ad33826
WIP
Fokko 302c60a
Merge branch 'fd-fix-overflowing-buffer' of github.com:Fokko/iceberg-…
Fokko 993c382
Refactor `{year,month,day,hour}` transform
Fokko 4cc2c5b
Merge branch 'main' of github.com:apache/iceberg-python into fd-fix-o…
Fokko d64d204
Merge branch 'main' of github.com:apache/iceberg-python into fd-fix-o…
Fokko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
import statistics | ||
import timeit | ||
import urllib | ||
|
||
import pyarrow as pa | ||
import pyarrow.parquet as pq | ||
import pytest | ||
|
||
from pyiceberg.transforms import DayTransform | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def taxi_dataset(tmp_path_factory: pytest.TempPathFactory) -> pa.Table: | ||
"""Reads the Taxi dataset to disk""" | ||
taxi_dataset = "https://d37ci6vzurychx.cloudfront.net/trip-data/yellow_tripdata_2022-01.parquet" | ||
taxi_dataset_dest = tmp_path_factory.mktemp("taxi_dataset") / "yellow_tripdata_2022-01.parquet" | ||
urllib.request.urlretrieve(taxi_dataset, taxi_dataset_dest) | ||
|
||
return pq.read_table(taxi_dataset_dest) | ||
|
||
|
||
@pytest.mark.benchmark | ||
def test_partitioned_write(tmp_path_factory: pytest.TempPathFactory, taxi_dataset: pa.Table) -> None: | ||
"""Tests writing to a partitioned table with something that would be close a production-like situation""" | ||
from pyiceberg.catalog.sql import SqlCatalog | ||
|
||
warehouse_path = str(tmp_path_factory.mktemp("warehouse")) | ||
catalog = SqlCatalog( | ||
"default", | ||
uri=f"sqlite:///{warehouse_path}/pyiceberg_catalog.db", | ||
warehouse=f"file://{warehouse_path}", | ||
) | ||
|
||
catalog.create_namespace("default") | ||
|
||
tbl = catalog.create_table("default.taxi_partitioned", schema=taxi_dataset.schema) | ||
|
||
with tbl.update_spec() as spec: | ||
spec.add_field("tpep_pickup_datetime", DayTransform()) | ||
|
||
# Profiling can sometimes be handy as well | ||
# with cProfile.Profile() as pr: | ||
# tbl.append(taxi_dataset) | ||
# | ||
# pr.print_stats(sort=True) | ||
|
||
runs = [] | ||
for run in range(5): | ||
start_time = timeit.default_timer() | ||
tbl.append(taxi_dataset) | ||
elapsed = timeit.default_timer() - start_time | ||
|
||
print(f"Run {run} took: {elapsed}") | ||
runs.append(elapsed) | ||
|
||
print(f"Average runtime of {round(statistics.mean(runs), 2)} seconds") |
This file contains 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
Oops, something went wrong.
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.
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 causing bugs, I'm going to revisit this to fix it properly
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.
Yes, so I got to the bottom of it. It has to do with the return types of the transforms. eg. When we apply the
bucket
transform, the result is always an int, which is great. The problem is with the identity transform where the destination type is equal to the source type. So when a date comes in, it also comes out.I think in the end it is better to remove the
_to_partition_representation
and see if we can consolidate this somewhere, but that's a different PR.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.
is it due to not having support for
datetime
literal? #1542There 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.
also if its just for adding files, perhaps we can do something special just for that path
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.
Yes, that's exactly what I went for. I think we can simplify the logic in subsequent PRs :)