| import pytest |
| from datafusion import SessionContext |
| import pyarrow as pa |
| |
| |
| @pytest.fixture |
| def ctx(): |
| return SessionContext() |
| |
| |
| @pytest.fixture |
| def database(ctx, tmp_path): |
| path = tmp_path / "test.csv" |
| |
| table = pa.Table.from_arrays( |
| [ |
| [1, 2, 3, 4], |
| ["a", "b", "c", "d"], |
| [1.1, 2.2, 3.3, 4.4], |
| ], |
| names=["int", "str", "float"], |
| ) |
| pa.csv.write_csv(table, path) |
| |
| ctx.register_csv("csv", path) |
| ctx.register_csv("csv1", str(path)) |
| ctx.register_csv( |
| "csv2", |
| path, |
| has_header=True, |
| delimiter=",", |
| schema_infer_max_records=10, |
| ) |