From 0f2dccf02f67d5804358507f4323f5190097e03d Mon Sep 17 00:00:00 2001 From: Tim Saucer Date: Thu, 5 Dec 2024 20:56:30 -0500 Subject: [PATCH] add unit test for parameterized sql statement --- python/tests/test_sql.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/tests/test_sql.py b/python/tests/test_sql.py index a2521dd0..f3de8a4a 100644 --- a/python/tests/test_sql.py +++ b/python/tests/test_sql.py @@ -159,6 +159,16 @@ def test_register_parquet(ctx, tmp_path): assert result.to_pydict() == {"cnt": [100]} +def test_parameterized_sql(ctx, tmp_path) -> None: + path = helpers.write_parquet(tmp_path / "a.parquet", helpers.data()) + df = ctx.read_parquet(path) + result = ctx.sql( + "SELECT COUNT(a) AS cnt FROM {replaced_df}", replaced_df=df + ).collect() + result = pa.Table.from_batches(result) + assert result.to_pydict() == {"cnt": [100]} + + @pytest.mark.parametrize("path_to_str", (True, False)) def test_register_parquet_partitioned(ctx, tmp_path, path_to_str): dir_root = tmp_path / "dataset_parquet_partitioned"