Skip to content

Commit

Permalink
test_apply_limit_with_predicate for 335c67a
Browse files Browse the repository at this point in the history
  • Loading branch information
parkervg committed Jun 22, 2024
1 parent b2f0c2f commit d4022e5
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/test_single_table_blendsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,5 +565,35 @@ def test_apply_limit(db, ingredients):
assert smoothie.meta.num_values_passed == 1


@pytest.mark.parametrize("db", databases)
def test_apply_limit_with_predicate(db, ingredients):
# commit 335c67a
blendsql = """
SELECT {{get_length('length', 'transactions::merchant')}}
FROM transactions
WHERE amount > 1300
ORDER BY merchant LIMIT 3
"""
sql = """
SELECT LENGTH(merchant)
FROM transactions
WHERE amount > 1300
ORDER BY merchant LIMIT 3
"""
smoothie = blend(
query=blendsql,
db=db,
ingredients=ingredients,
)
sql_df = db.execute_to_df(sql)
assert_equality(smoothie=smoothie, sql_df=sql_df)
# Make sure we only pass what's necessary to our ingredient
passed_to_ingredient = db.execute_to_list(
"""
SELECT COUNT(DISTINCT merchant) FROM transactions WHERE amount > 1300 LIMIT 3 """
)[0]
assert smoothie.meta.num_values_passed == passed_to_ingredient


if __name__ == "__main__":
pytest.main()

0 comments on commit d4022e5

Please sign in to comment.