|
18 | 18 | import math |
19 | 19 | import os |
20 | 20 | import random |
| 21 | +import re |
21 | 22 | import time |
22 | 23 | import uuid |
23 | 24 | from datetime import date, datetime, timedelta |
|
44 | 45 | from pyiceberg.catalog.sql import SqlCatalog |
45 | 46 | from pyiceberg.exceptions import CommitFailedException, NoSuchTableError |
46 | 47 | from 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 |
48 | 49 | from pyiceberg.partitioning import PartitionField, PartitionSpec |
49 | 50 | from pyiceberg.schema import Schema |
50 | 51 | from pyiceberg.table import TableProperties |
@@ -2249,15 +2250,24 @@ def test_branch_py_write_spark_read(session_catalog: Catalog, spark: SparkSessio |
2249 | 2250 |
|
2250 | 2251 |
|
2251 | 2252 | @pytest.mark.integration |
2252 | | -def test_nanosecond_support_on_catalog(session_catalog: Catalog) -> None: |
| 2253 | +def test_nanosecond_support_on_catalog( |
| 2254 | + session_catalog: Catalog, arrow_table_schema_with_all_timestamp_precisions: pa.Schema |
| 2255 | +) -> None: |
2253 | 2256 | 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 | | - ) |
2262 | 2257 |
|
2263 | | - _create_table(session_catalog, identifier, {"format-version": "3"}, schema=table.schema) |
| 2258 | + catalog = load_catalog("default", type="in-memory") |
| 2259 | + catalog.create_namespace("ns") |
| 2260 | + |
| 2261 | + _create_table(session_catalog, identifier, {"format-version": "3"}, schema=arrow_table_schema_with_all_timestamp_precisions) |
| 2262 | + |
| 2263 | + with pytest.raises(NotImplementedError, match="Writing V3 is not yet supported"): |
| 2264 | + catalog.create_table( |
| 2265 | + "ns.table1", schema=arrow_table_schema_with_all_timestamp_precisions, properties={"format-version": "3"} |
| 2266 | + ) |
| 2267 | + |
| 2268 | + with pytest.raises( |
| 2269 | + UnsupportedPyArrowTypeException, match=re.escape("Column 'timestamp_ns' has an unsupported type: timestamp[ns]") |
| 2270 | + ): |
| 2271 | + _create_table( |
| 2272 | + session_catalog, identifier, {"format-version": "2"}, schema=arrow_table_schema_with_all_timestamp_precisions |
| 2273 | + ) |
0 commit comments