Skip to content

Commit

Permalink
add unit test for parameterized sql statement
Browse files Browse the repository at this point in the history
  • Loading branch information
timsaucer committed Dec 6, 2024
1 parent fd5977f commit 0f2dccf
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions python/tests/test_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 0f2dccf

Please sign in to comment.