-
Notifications
You must be signed in to change notification settings - Fork 170
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
fix: support MonthTransform for partitioning #1176
Merged
kevinjqliu
merged 4 commits into
apache:main
from
felixscherz:feat/month-partition-transform
Sep 16, 2024
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,14 @@ def test_add_year(catalog: Catalog) -> None: | |
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, YearTransform(), "year_transform")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_year_generates_default_name(catalog: Catalog) -> None: | ||
table = _table(catalog) | ||
table.update_spec().add_field("event_ts", YearTransform()).commit() | ||
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, YearTransform(), "event_ts_year")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_month(catalog: Catalog) -> None: | ||
|
@@ -100,6 +108,13 @@ def test_add_month(catalog: Catalog) -> None: | |
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, MonthTransform(), "month_transform")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_month_generates_default_name(catalog: Catalog) -> None: | ||
table = _table(catalog) | ||
table.update_spec().add_field("event_ts", MonthTransform()).commit() | ||
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, MonthTransform(), "event_ts_month")) | ||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_day(catalog: Catalog) -> None: | ||
|
@@ -108,6 +123,14 @@ def test_add_day(catalog: Catalog) -> None: | |
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, DayTransform(), "day_transform")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_day_generates_default_name(catalog: Catalog) -> None: | ||
table = _table(catalog) | ||
table.update_spec().add_field("event_ts", DayTransform()).commit() | ||
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, DayTransform(), "event_ts_day")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_hour(catalog: Catalog) -> None: | ||
|
@@ -116,6 +139,14 @@ def test_add_hour(catalog: Catalog) -> None: | |
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, HourTransform(), "hour_transform")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_hour_generates_default_name(catalog: Catalog) -> None: | ||
table = _table(catalog) | ||
table.update_spec().add_field("event_ts", HourTransform()).commit() | ||
_validate_new_partition_fields(table, 1000, 1, 1000, PartitionField(2, 1000, HourTransform(), "event_ts_hour")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_bucket(catalog: Catalog, table_schema_simple: Schema) -> None: | ||
|
@@ -124,6 +155,14 @@ def test_add_bucket(catalog: Catalog, table_schema_simple: Schema) -> None: | |
_validate_new_partition_fields(simple_table, 1000, 1, 1000, PartitionField(1, 1000, BucketTransform(12), "bucket_transform")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_bucket_generates_default_name(catalog: Catalog, table_schema_simple: Schema) -> None: | ||
simple_table = _create_table_with_schema(catalog, table_schema_simple, "1") | ||
simple_table.update_spec().add_field("foo", BucketTransform(12)).commit() | ||
_validate_new_partition_fields(simple_table, 1000, 1, 1000, PartitionField(1, 1000, BucketTransform(12), "foo_bucket_12")) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_truncate(catalog: Catalog, table_schema_simple: Schema) -> None: | ||
|
@@ -134,6 +173,16 @@ def test_add_truncate(catalog: Catalog, table_schema_simple: Schema) -> None: | |
) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_truncate_generates_default_name(catalog: Catalog, table_schema_simple: Schema) -> None: | ||
simple_table = _create_table_with_schema(catalog, table_schema_simple, "1") | ||
simple_table.update_spec().add_field("foo", TruncateTransform(1)).commit() | ||
_validate_new_partition_fields( | ||
simple_table, 1000, 1, 1000, PartitionField(1, 1000, TruncateTransform(1), "foo_trunc_1") | ||
) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_multiple_adds(catalog: Catalog) -> None: | ||
|
@@ -152,6 +201,36 @@ def test_multiple_adds(catalog: Catalog) -> None: | |
) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_void(catalog: Catalog, table_schema_simple: Schema) -> None: | ||
simple_table = _create_table_with_schema(catalog, table_schema_simple, "1") | ||
simple_table.update_spec().add_field("foo", VoidTransform(), "void_transform").commit() | ||
_validate_new_partition_fields( | ||
simple_table, 1000, 1, 1000, PartitionField(1, 1000, VoidTransform(), "void_transform") | ||
) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_void_generates_default_name(catalog: Catalog, table_schema_simple: Schema) -> None: | ||
simple_table = _create_table_with_schema(catalog, table_schema_simple, "1") | ||
simple_table.update_spec().add_field("foo", VoidTransform()).commit() | ||
_validate_new_partition_fields( | ||
simple_table, 1000, 1, 1000, PartitionField(1, 1000, VoidTransform(), "foo_null") | ||
) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_truncate_generates_default_name(catalog: Catalog, table_schema_simple: Schema) -> None: | ||
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. nit: this is defined twice, remove this one 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. Thank you for catching that, removed it! |
||
simple_table = _create_table_with_schema(catalog, table_schema_simple, "1") | ||
simple_table.update_spec().add_field("foo", TruncateTransform(1)).commit() | ||
_validate_new_partition_fields( | ||
simple_table, 1000, 1, 1000, PartitionField(1, 1000, TruncateTransform(1), "foo_trunc_1") | ||
) | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog_hive"), pytest.lazy_fixture("session_catalog")]) | ||
def test_add_hour_to_day(catalog: Catalog) -> None: | ||
|
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.
nit: it seems like there's no test for the "default name" for any of the transforms. do you mind adding those as well?
https://github.com/apache/iceberg-python/pull/1176/files#diff-428471774c19f5aef70af04a0b2dcbbc263c2c8b372dbc3993356e2c851539ecR310-R336
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 of course, I'll add them:)