|
18 | 18 | import json |
19 | 19 | import uuid |
20 | 20 | from copy import copy |
21 | | -from pathlib import Path |
22 | 21 | from typing import Any |
23 | 22 |
|
24 | 23 | import pytest |
@@ -2063,40 +2062,3 @@ def mock_scan_iceberg(source: Any, **kwargs: Any) -> Any: |
2063 | 2062 | table_v2, |
2064 | 2063 | {"storage_options": storage_options, "snapshot_id": 12345, "reader_override": "native"}, |
2065 | 2064 | ) |
2066 | | - |
2067 | | - |
2068 | | -def test_table_to_polars_e2e(tmp_path: Path) -> None: |
2069 | | - import pyarrow as pa |
2070 | | - |
2071 | | - from pyiceberg.catalog.sql import SqlCatalog |
2072 | | - from pyiceberg.schema import Schema |
2073 | | - from pyiceberg.types import IntegerType, NestedField, StringType |
2074 | | - |
2075 | | - catalog = SqlCatalog("test_sql", uri=f"sqlite:///{tmp_path}/test.db", warehouse=f"file://{tmp_path}") |
2076 | | - catalog.create_namespace("default") |
2077 | | - schema = Schema( |
2078 | | - NestedField(1, "id", IntegerType(), required=True), |
2079 | | - NestedField(2, "name", StringType(), required=True), |
2080 | | - ) |
2081 | | - table = catalog.create_table("default.test_polars", schema=schema) |
2082 | | - arrow_table = pa.Table.from_pylist( |
2083 | | - [{"id": 1, "name": "alice"}, {"id": 2, "name": "bob"}], |
2084 | | - schema=schema.as_arrow(), |
2085 | | - ) |
2086 | | - table.append(arrow_table) |
2087 | | - |
2088 | | - # 1. E2E without kwargs |
2089 | | - lf = table.to_polars() |
2090 | | - df = lf.collect() |
2091 | | - assert df.shape == (2, 2) |
2092 | | - assert df["id"].to_list() == [1, 2] |
2093 | | - assert df["name"].to_list() == ["alice", "bob"] |
2094 | | - |
2095 | | - # 2. E2E with real kwargs (snapshot_id) |
2096 | | - current_snap = table.current_snapshot() |
2097 | | - assert current_snap is not None |
2098 | | - lf_snap = table.to_polars(snapshot_id=current_snap.snapshot_id) |
2099 | | - df_snap = lf_snap.collect() |
2100 | | - assert df_snap.shape == (2, 2) |
2101 | | - assert df_snap["id"].to_list() == [1, 2] |
2102 | | - assert df_snap["name"].to_list() == ["alice", "bob"] |
0 commit comments