Repository navigation
Finally! Getting the early exit and cascade filter optimization working for queries where the LM functions reference values from multiple tables (e.g. after performing some JOIN). It's probably best illustrated in the following new test case:
def test_early_exit_across_joined_tables(self, bsql):
"""Early exit should apply to the final Map ingredient when it's on a different,
joined table than the previous Map ingredient (via the cross-table cascade filter).
Customers 1 (Chile) and 5 (Canada) survive the first filter. Their orders only have
statuses 'completed' and 'pending', both of which don't start with 's'. So with
`LIMIT 1`, we can exit after processing a single status.
"""
smoothie = bsql.execute(
"""
SELECT c.customer_id, o.order_id FROM customers c
JOIN orders o ON c.customer_id = o.customer_id
WHERE {{test_starts_with('C', c.country)}} = TRUE
AND {{test_starts_with('s', o.status)}} = FALSE
LIMIT 1
"""
)
assert smoothie.df().values.tolist()[0] in [[1, 101], [1, 102], [5, 108]]
# 5 distinct countries + 1 status, instead of 5 + 2 without early exit
assert smoothie.meta.num_values_passed == 6Full Changelog: v0.1.27...v0.1.28