Skip to content

Commit 0f2dccf

Browse files
committed
add unit test for parameterized sql statement
1 parent fd5977f commit 0f2dccf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

python/tests/test_sql.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ def test_register_parquet(ctx, tmp_path):
159159
assert result.to_pydict() == {"cnt": [100]}
160160

161161

162+
def test_parameterized_sql(ctx, tmp_path) -> None:
163+
path = helpers.write_parquet(tmp_path / "a.parquet", helpers.data())
164+
df = ctx.read_parquet(path)
165+
result = ctx.sql(
166+
"SELECT COUNT(a) AS cnt FROM {replaced_df}", replaced_df=df
167+
).collect()
168+
result = pa.Table.from_batches(result)
169+
assert result.to_pydict() == {"cnt": [100]}
170+
171+
162172
@pytest.mark.parametrize("path_to_str", (True, False))
163173
def test_register_parquet_partitioned(ctx, tmp_path, path_to_str):
164174
dir_root = tmp_path / "dataset_parquet_partitioned"

0 commit comments

Comments
 (0)