From c83195400ff5a928659c351e2bf654cbed8bc03a Mon Sep 17 00:00:00 2001 From: Jasper Ginn Date: Sun, 20 Oct 2024 21:00:25 +0200 Subject: [PATCH] fix: tests --- .../dagster_pyiceberg/src/dagster_pyiceberg/handler.py | 5 +++-- tests/dagster_pyiceberg/test_handler.py | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/dagster_pyiceberg/src/dagster_pyiceberg/handler.py b/packages/dagster_pyiceberg/src/dagster_pyiceberg/handler.py index ec2a526..d13625e 100644 --- a/packages/dagster_pyiceberg/src/dagster_pyiceberg/handler.py +++ b/packages/dagster_pyiceberg/src/dagster_pyiceberg/handler.py @@ -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( @@ -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 diff --git a/tests/dagster_pyiceberg/test_handler.py b/tests/dagster_pyiceberg/test_handler.py index a8e4680..9a11991 100644 --- a/tests/dagster_pyiceberg/test_handler.py +++ b/tests/dagster_pyiceberg/test_handler.py @@ -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( @@ -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" ) @@ -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", @@ -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)