1515# specific language governing permissions and limitations
1616# under the License.
1717# pylint:disable=redefined-outer-name
18- from typing import Optional
1918
2019import pytest
2120
2221from pyiceberg .catalog import Catalog
2322from pyiceberg .exceptions import NoSuchTableError
24- from pyiceberg .partitioning import PartitionField , PartitionSpec
23+ from pyiceberg .partitioning import UNPARTITIONED_PARTITION_SPEC , PartitionField , PartitionSpec
2524from pyiceberg .schema import Schema
2625from pyiceberg .table import Table
2726from pyiceberg .transforms import (
@@ -65,7 +64,7 @@ def _table_v2(catalog: Catalog) -> Table:
6564
6665
6766def _create_table_with_schema (
68- catalog : Catalog , schema : Schema , format_version : str , partition_spec : Optional [ PartitionSpec ] = None
67+ catalog : Catalog , schema : Schema , format_version : str , partition_spec : PartitionSpec = UNPARTITIONED_PARTITION_SPEC
6968) -> Table :
7069 tbl_name = "default.test_schema_evolution"
7170 try :
@@ -77,7 +76,9 @@ def _create_table_with_schema(
7776 return catalog .create_table (
7877 identifier = tbl_name , schema = schema , partition_spec = partition_spec , properties = {"format-version" : format_version }
7978 )
80- return catalog .create_table (identifier = tbl_name , schema = schema , properties = {"format-version" : format_version })
79+ return catalog .create_table (
80+ identifier = tbl_name , schema = schema , partition_spec = partition_spec , properties = {"format-version" : format_version }
81+ )
8182
8283
8384@pytest .mark .integration
@@ -590,11 +591,9 @@ def test_partition_schema_field_name_conflict(catalog: Catalog) -> None:
590591 with pytest .raises (ValueError , match = "Cannot create partition from name that exists in schema: id" ):
591592 table .update_spec ().add_field ("event_ts" , DayTransform (), "id" ).commit ()
592593
593- with pytest .raises (
594- ValueError , match = "Cannot create identity partition from a different source field in the schema: another_ts"
595- ):
594+ with pytest .raises (ValueError , match = "Cannot create identity partition sourced from different field in schema: another_ts" ):
596595 table .update_spec ().add_field ("event_ts" , IdentityTransform (), "another_ts" ).commit ()
597- with pytest .raises (ValueError , match = "Cannot create identity partition from a different source field in the schema: str" ):
596+ with pytest .raises (ValueError , match = "Cannot create identity partition sourced from different field in schema: str" ):
598597 table .update_spec ().add_field ("id" , IdentityTransform (), "str" ).commit ()
599598
600599 table .update_spec ().add_field ("id" , IdentityTransform (), "id" ).commit ()
@@ -640,18 +639,14 @@ def test_schema_evolution_partition_conflict(catalog: Catalog) -> None:
640639
641640 with pytest .raises (ValueError , match = "Cannot create partition from name that exists in schema: event_year" ):
642641 table .update_schema ().add_column ("event_year" , StringType ()).commit ()
643- with pytest .raises (
644- ValueError , match = "Cannot create identity partition from a different source field in the schema: first_name"
645- ):
642+ with pytest .raises (ValueError , match = "Cannot create identity partition sourced from different field in schema: first_name" ):
646643 table .update_schema ().add_column ("first_name" , StringType ()).commit ()
647644
648645 table .update_schema ().add_column ("other_field" , StringType ()).commit ()
649646
650647 with pytest .raises (ValueError , match = "Cannot create partition from name that exists in schema: event_year" ):
651648 table .update_schema ().rename_column ("other_field" , "event_year" ).commit ()
652- with pytest .raises (
653- ValueError , match = "Cannot create identity partition from a different source field in the schema: first_name"
654- ):
649+ with pytest .raises (ValueError , match = "Cannot create identity partition sourced from different field in schema: first_name" ):
655650 table .update_schema ().rename_column ("other_field" , "first_name" ).commit ()
656651
657652 table .update_schema ().rename_column ("other_field" , "valid_name" ).commit ()
0 commit comments