Skip to content
This repository has been archived by the owner on Feb 20, 2025. It is now read-only.

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperHG90 committed Oct 20, 2024
1 parent 6de060e commit c831954
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/dagster_pyiceberg/src/dagster_pyiceberg/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,11 @@ def updated_time_partition_field(self) -> str | None:
This happens when users change e.g. from an hourly to a daily partition."""
# The assumption is that even a multi-partitioned table will have only one time partition
time_partition = next(iter(self.dagster_time_partitions))
time_partition_partitions = cast(TimeWindow, time_partition.partitions)
updated_field_name: str | None = None
if time_partition is not None:
time_partition_transformation = diff_to_transformation(
time_partition.partitions.start, time_partition.partitions.end
time_partition_partitions.start, time_partition_partitions.end
)
# Check if field is present in iceberg partition spec
current_time_partition_field = self.get_iceberg_partition_field_by_name(
Expand Down Expand Up @@ -336,7 +337,7 @@ def _spec_update(self, update: UpdateSpec, partition: TablePartitionDimension):

def _spec_delete(self, update: UpdateSpec, partition_name: str):
try:
update.remove_field(partition_name=partition_name)
update.remove_field(name=partition_name)
except ValueError:
# Already deleted by another operation
pass
Expand Down
8 changes: 4 additions & 4 deletions tests/dagster_pyiceberg/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def test_table_writer_multi_partitioned_update_partition_spec_error(
& (pc.field("timestamp") < dt.datetime(2023, 1, 1, 1))
)
with pytest.raises(
ValueError, match="Schema update mode is set to 'error' but there"
ValueError, match="Partition spec update mode is set to 'error' but there"
):
handler._table_writer(
table_slice=TableSlice(
Expand Down Expand Up @@ -588,7 +588,7 @@ def test_iceberg_table_spec_updater_delete_field(
spec_updater.update_table_spec(table=mock_iceberg_table)
mock_iceberg_table.update_spec.assert_called_once()
mock_iceberg_table.update_spec.return_value.__enter__.return_value.remove_field.assert_called_once_with(
partition_name="category"
name="category"
)


Expand Down Expand Up @@ -622,7 +622,7 @@ def test_iceberg_table_spec_updater_update_field(
spec_updater.update_table_spec(table=mock_iceberg_table)
mock_iceberg_table.update_spec.assert_called_once()
mock_iceberg_table.update_spec.return_value.__enter__.return_value.remove_field.assert_called_once_with(
partition_name="timestamp"
name="timestamp"
)
mock_iceberg_table.update_spec.return_value.__enter__.return_value.add_field.assert_called_once_with(
source_column_name="timestamp",
Expand Down Expand Up @@ -686,5 +686,5 @@ def test_iceberg_table_spec_updater_fails_with_error_update_mode(
partition_spec_update_mode="error",
)
mock_iceberg_table = mock.MagicMock()
with pytest.raises(ValueError, match="Schema update mode is set to"):
with pytest.raises(ValueError, match="Partition spec update mode is set to"):
spec_updater.update_table_spec(table=mock_iceberg_table)

0 comments on commit c831954

Please sign in to comment.