Skip to content

Commit 63b9202

Browse files
thomasht86claude
andcommitted
Make range_ tests return full YQL queries for test_all compatibility
Range tests were returning None, causing test_all to pass None as YQL to Vespa. Now they build complete queries using the test schema. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ef8e387 commit 63b9202

1 file changed

Lines changed: 36 additions & 9 deletions

File tree

tests/unit/test_grouping.py

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -881,21 +881,48 @@ def test_filter_double_not(self):
881881
def test_range_lower_inclusive_only(self):
882882
# Vespa defaults: lower inclusive (true), upper exclusive (false)
883883
# Setting only lower_inclusive should use the default for upper (false)
884-
expr = G.range_(1990, 2012, "year", False)
885-
expected = "range(1990, 2012, year, false, false)"
886-
assert str(expr) == expected, f"\n{expr}\n\ndiffers from:\n\n{expected}"
884+
grouping = G.all(
885+
G.group("a"),
886+
G.filter_(G.range_(1, 5, "n", False)),
887+
G.each(G.output(G.count())),
888+
)
889+
q = qb.select("*").from_("test").where(True).groupby(grouping)
890+
expected = (
891+
"select * from test where true "
892+
"| all(group(a) filter(range(1, 5, n, false, false)) each(output(count())))"
893+
)
894+
assert q == expected, f"\nq:\n{q}\n\ndiffers from:\n\n{expected}"
895+
return q
887896

888897
def test_range_both_explicit(self):
889898
# Setting both explicitly
890-
expr = G.range_(1990, 2012, "year", True, True)
891-
expected = "range(1990, 2012, year, true, true)"
892-
assert str(expr) == expected, f"\n{expr}\n\ndiffers from:\n\n{expected}"
899+
grouping = G.all(
900+
G.group("a"),
901+
G.filter_(G.range_(1, 5, "n", True, True)),
902+
G.each(G.output(G.count())),
903+
)
904+
q = qb.select("*").from_("test").where(True).groupby(grouping)
905+
expected = (
906+
"select * from test where true "
907+
"| all(group(a) filter(range(1, 5, n, true, true)) each(output(count())))"
908+
)
909+
assert q == expected, f"\nq:\n{q}\n\ndiffers from:\n\n{expected}"
910+
return q
893911

894912
def test_range_upper_inclusive_only(self):
895913
# Setting only upper_inclusive should use the default for lower (true)
896-
expr = G.range_(1990, 2012, "year", upper_inclusive=True)
897-
expected = "range(1990, 2012, year, true, true)"
898-
assert str(expr) == expected, f"\n{expr}\n\ndiffers from:\n\n{expected}"
914+
grouping = G.all(
915+
G.group("a"),
916+
G.filter_(G.range_(1, 5, "n", upper_inclusive=True)),
917+
G.each(G.output(G.count())),
918+
)
919+
q = qb.select("*").from_("test").where(True).groupby(grouping)
920+
expected = (
921+
"select * from test where true "
922+
"| all(group(a) filter(range(1, 5, n, true, true)) each(output(count())))"
923+
)
924+
assert q == expected, f"\nq:\n{q}\n\ndiffers from:\n\n{expected}"
925+
return q
899926

900927
def test_filter_multiple_groupings(self):
901928
g1 = G.all(

0 commit comments

Comments
 (0)