1818import math
1919import os
2020import random
21+ import re
2122import time
2223import uuid
2324from datetime import date , datetime , timedelta
4445from pyiceberg .catalog .sql import SqlCatalog
4546from pyiceberg .exceptions import CommitFailedException , NoSuchTableError
4647from pyiceberg .expressions import And , EqualTo , GreaterThanOrEqual , In , LessThan , Not
47- from pyiceberg .io .pyarrow import _dataframe_to_data_files
48+ from pyiceberg .io .pyarrow import UnsupportedPyArrowTypeException , _dataframe_to_data_files
4849from pyiceberg .partitioning import PartitionField , PartitionSpec
4950from pyiceberg .schema import Schema
5051from pyiceberg .table import TableProperties
@@ -2249,15 +2250,16 @@ def test_branch_py_write_spark_read(session_catalog: Catalog, spark: SparkSessio
22492250
22502251
22512252@pytest .mark .integration
2252- def test_nanosecond_support_on_catalog (session_catalog : Catalog ) -> None :
2253+ def test_nanosecond_support_on_catalog (session_catalog : Catalog , arrow_table_schema_with_all_timestamp_precisions : pa . Schema ) -> None :
22532254 identifier = "default.test_nanosecond_support_on_catalog"
2254- # Create a pyarrow table with a nanosecond timestamp column
2255- table = pa .Table .from_arrays (
2256- [
2257- pa .array ([datetime .now ()], type = pa .timestamp ("ns" )),
2258- pa .array ([datetime .now ()], type = pa .timestamp ("ns" , tz = "America/New_York" )),
2259- ],
2260- names = ["timestamp_ns" , "timestamptz_ns" ],
2261- )
22622255
2263- _create_table (session_catalog , identifier , {"format-version" : "3" }, schema = table .schema )
2256+ catalog = load_catalog ("default" , type = "in-memory" )
2257+ catalog .create_namespace ("ns" )
2258+
2259+ _create_table (session_catalog , identifier , {"format-version" : "3" }, schema = arrow_table_schema_with_all_timestamp_precisions )
2260+
2261+ with pytest .raises (NotImplementedError , match = "Writing V3 is not yet supported" ):
2262+ catalog .create_table ("ns.table1" , schema = arrow_table_schema_with_all_timestamp_precisions , properties = {"format-version" : "3" })
2263+
2264+ with pytest .raises (UnsupportedPyArrowTypeException , match = re .escape ("Column 'timestamp_ns' has an unsupported type: timestamp[ns]" )):
2265+ _create_table (session_catalog , identifier , {"format-version" : "2" }, schema = arrow_table_schema_with_all_timestamp_precisions )
0 commit comments