Skip to content
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

Implement column projection #1443

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

gabeiglio
Copy link

@gabeiglio gabeiglio commented Dec 18, 2024

This is a fix for issue #1401. In which table scans needed to infer partition column by following the column projection rules

Fixes #1401

@Fokko Fokko self-requested a review December 18, 2024 20:38
@gabeiglio gabeiglio marked this pull request as ready for review December 19, 2024 15:12
Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments, please take a look! The PR looks great already. Thanks for working on this!

pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
tests/io/test_pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
@kevinjqliu kevinjqliu self-requested a review December 23, 2024 19:04
…tion logic to helper method, changed test to use high-level table scan
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
tests/io/test_pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
pyiceberg/io/pyarrow.py Outdated Show resolved Hide resolved
@Fokko Fokko self-requested a review January 13, 2025 12:48
Copy link
Contributor

@kevinjqliu kevinjqliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally LGTM! I added a few nit comments and some clarifying questions on testing.

thanks for working on this!

tests/io/test_pyarrow.py Show resolved Hide resolved
pyiceberg/io/pyarrow.py Show resolved Hide resolved
pyiceberg/io/pyarrow.py Show resolved Hide resolved
Comment on lines +1279 to +1287
project_schema_diff = projected_field_ids.difference(file_project_schema.field_ids)
should_project_columns = len(project_schema_diff) > 0

projected_missing_fields = {}

if should_project_columns and partition_spec is not None:
projected_missing_fields = _get_column_projection_values(
task.file, projected_schema, project_schema_diff, partition_spec
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: wdyt about structuring the code like this?

Suggested change
project_schema_diff = projected_field_ids.difference(file_project_schema.field_ids)
should_project_columns = len(project_schema_diff) > 0
projected_missing_fields = {}
if should_project_columns and partition_spec is not None:
projected_missing_fields = _get_column_projection_values(
task.file, projected_schema, project_schema_diff, partition_spec
)
should_project_columns, projected_missing_fields = _get_column_projection_values(
task.file, projected_schema, partition_spec
)

and in _get_column_projection_values, move the rest of the logic

def _get_column_projection_values(...):
        project_schema_diff = projected_field_ids.difference(file_project_schema.field_ids)
        should_project_columns = len(project_schema_diff) > 0
        projected_missing_fields = {}
        if not should_project_columns:
                return False, {}         
        ...

tests/io/test_pyarrow.py Show resolved Hide resolved
Comment on lines +1196 to +1199
partition_spec = PartitionSpec(
PartitionField(2, 1000, VoidTransform(), "void_partition_id"),
PartitionField(2, 1001, IdentityTransform(), "partition_id"),
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we'd want to test multiple IdentityTransforms here.

im thinking about a case for multiple-level of partitioning in hive-style.

s3://my_table/a=100/b=foo/...parquet

i think _get_column_projection_values might not support this right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API table.scan does not conform to Iceberg spec for identity partition columns
3 participants