(request, tmp_path)
| 27 | |
| 28 | @pytest.fixture |
| 29 | def catalog(request, tmp_path): |
| 30 | # the catalog stores the full path of data files, so the catalog needs to be |
| 31 | # created dynamically, and not saved in pandas/tests/io/data as other formats |
| 32 | uri = f"sqlite:///{tmp_path}/catalog.sqlite" |
| 33 | warehouse = f"file://{tmp_path}" |
| 34 | catalog_name = request.param if hasattr(request, "param") else None |
| 35 | catalog = pyiceberg_catalog.load_catalog( |
| 36 | catalog_name or "default", |
| 37 | type="sql", |
| 38 | uri=uri, |
| 39 | warehouse=warehouse, |
| 40 | ) |
| 41 | catalog.create_namespace("ns") |
| 42 | |
| 43 | df = pq.read_table( |
| 44 | pathlib.Path(__file__).parent / "data" / "parquet" / "simple.parquet" |
| 45 | ) |
| 46 | table = catalog.create_table("ns.my_table", schema=df.schema) |
| 47 | table.append(df) |
| 48 | |
| 49 | if catalog_name is not None: |
| 50 | config_path = pathlib.Path.home() / ".pyiceberg.yaml" |
| 51 | with open(config_path, "w", encoding="utf-8") as f: |
| 52 | f.write(f"""\ |
| 53 | catalog: |
| 54 | {catalog_name}: |
| 55 | type: sql |
| 56 | uri: {uri} |
| 57 | warehouse: {warehouse}""") |
| 58 | |
| 59 | importlib.reload(pyiceberg_catalog) # needed to reload the config file |
| 60 | |
| 61 | yield Catalog(name=catalog_name or "default", uri=uri, warehouse=warehouse) |
| 62 | |
| 63 | if catalog_name is not None: |
| 64 | config_path.unlink() |
| 65 | |
| 66 | |
| 67 | class TestIceberg: |
nothing calls this directly
no test coverage detected