|
64 | 64 | StringType, |
65 | 65 | UUIDType, |
66 | 66 | ) |
67 | | -from utils import _create_table |
| 67 | +from utils import TABLE_SCHEMA, _create_table |
68 | 68 |
|
69 | 69 |
|
70 | 70 | @pytest.fixture(scope="session", autouse=True) |
@@ -2490,3 +2490,41 @@ def test_stage_only_overwrite_files( |
2490 | 2490 | assert operations == ["append", "append", "delete", "append", "append"] |
2491 | 2491 |
|
2492 | 2492 | assert parent_snapshot_id == [None, first_snapshot, second_snapshot, second_snapshot, second_snapshot] |
| 2493 | + |
| 2494 | + |
| 2495 | +@pytest.mark.skip("V3 writer support is not enabled.") |
| 2496 | +@pytest.mark.integration |
| 2497 | +def test_v3_write_and_read_row_lineage(spark: SparkSession, session_catalog: Catalog) -> None: |
| 2498 | + """Test writing to a v3 table and reading with Spark.""" |
| 2499 | + identifier = "default.test_v3_write_and_read" |
| 2500 | + tbl = _create_table(session_catalog, identifier, {"format-version": "3"}) |
| 2501 | + assert tbl.format_version == 3, f"Expected v3, got: v{tbl.format_version}" |
| 2502 | + initial_next_row_id = tbl.metadata.next_row_id or 0 |
| 2503 | + |
| 2504 | + test_data = pa.Table.from_pydict( |
| 2505 | + { |
| 2506 | + "bool": [True, False, True], |
| 2507 | + "string": ["a", "b", "c"], |
| 2508 | + "string_long": ["a_long", "b_long", "c_long"], |
| 2509 | + "int": [1, 2, 3], |
| 2510 | + "long": [11, 22, 33], |
| 2511 | + "float": [1.1, 2.2, 3.3], |
| 2512 | + "double": [1.11, 2.22, 3.33], |
| 2513 | + "timestamp": [datetime(2023, 1, 1, 1, 1, 1), datetime(2023, 2, 2, 2, 2, 2), datetime(2023, 3, 3, 3, 3, 3)], |
| 2514 | + "timestamptz": [ |
| 2515 | + datetime(2023, 1, 1, 1, 1, 1, tzinfo=pytz.utc), |
| 2516 | + datetime(2023, 2, 2, 2, 2, 2, tzinfo=pytz.utc), |
| 2517 | + datetime(2023, 3, 3, 3, 3, 3, tzinfo=pytz.utc), |
| 2518 | + ], |
| 2519 | + "date": [date(2023, 1, 1), date(2023, 2, 2), date(2023, 3, 3)], |
| 2520 | + "binary": [b"\x01", b"\x02", b"\x03"], |
| 2521 | + "fixed": [b"1234567890123456", b"1234567890123456", b"1234567890123456"], |
| 2522 | + }, |
| 2523 | + schema=TABLE_SCHEMA.as_arrow(), |
| 2524 | + ) |
| 2525 | + |
| 2526 | + tbl.append(test_data) |
| 2527 | + |
| 2528 | + assert tbl.metadata.next_row_id == initial_next_row_id + len(test_data), ( |
| 2529 | + "Expected next_row_id to be incremented by the number of added rows" |
| 2530 | + ) |
0 commit comments