Skip to content

Commit

Permalink
SNOW-1642105: Add variable binding test (#2425)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-aalam authored Oct 11, 2024
1 parent 078cdf6 commit 25f976c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/integ/test_large_query_breakdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,31 @@ def test_save_as_table(session, large_query_df):
assert history.queries[3].sql_text.startswith("DROP TABLE If EXISTS")


def test_variable_binding(session):
if not session.sql_simplifier_enabled:
set_bounds(session, 40, 80)

df1 = session.sql(
"select $1 as A, $2 as B from values (?,?), (?,?)", params=[1, "a", 2, "b"]
)
df2 = session.sql(
"select $1 as A, $2 as B from values (?,?), (?,?)", params=[3, "c", 4, "d"]
)

for i in range(7):
df1 = df1.with_column("A", col("A") + i + col("A"))
df2 = df2.with_column("A", col("A") + i + col("A"))
df1 = df1.group_by("B").agg(sum_distinct(col("A")).alias("A"))
df2 = df2.group_by("B").agg(sum_distinct(col("A")).alias("A"))
final_df = df1.union_all(df2)

check_result_with_and_without_breakdown(session, final_df)
with SqlCounter(query_count=1, describe_count=0):
queries = final_df.queries
assert len(queries["queries"]) == 2
assert len(queries["post_actions"]) == 1


def test_update_delete_merge(session, large_query_df):
if not session.sql_simplifier_enabled:
pytest.skip(
Expand Down

0 comments on commit 25f976c

Please sign in to comment.