Skip to content

Commit b6e8f29

Browse files
luis-dkclaude
andcommitted
fix(test-execution): tolerate NULL max_query_chars in CAT batching
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 91a3fb7 commit b6e8f29

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

testgen/commands/queries/execute_tests_query.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
is_excluded_day,
2222
resolve_holiday_dates,
2323
)
24-
from testgen.common.models.connection import Connection
24+
from testgen.common.models.connection import DEFAULT_MAX_QUERY_CHARS, Connection
2525
from testgen.common.models.scheduler import JobSchedule
2626
from testgen.common.models.table_group import TableGroup
2727
from testgen.common.models.test_definition import TestRunType, TestScope
@@ -534,7 +534,7 @@ def aggregate_cat_tests(
534534
null_value=self.null_value,
535535
)
536536

537-
max_query_chars = self.connection.max_query_chars - 400
537+
max_query_chars = (self.connection.max_query_chars or DEFAULT_MAX_QUERY_CHARS) - 400
538538
groups = group_cat_tests(test_defs, max_query_chars, concat_operator, single)
539539

540540
aggregate_queries: list[tuple[str, None]] = []

tests/unit/commands/queries/test_execute_tests_query.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
group_cat_tests,
1212
parse_cat_results,
1313
)
14+
from testgen.common.database.database_service import get_flavor_service
15+
from testgen.common.models.connection import Connection
1416

1517
pytestmark = pytest.mark.unit
1618

@@ -478,3 +480,18 @@ def test_resolve_cat_no_freshness_result_uses_band_check(_mock_changed):
478480
assert operator == "NOT BETWEEN"
479481

480482

483+
def test_aggregate_cat_tests_handles_null_max_query_chars():
484+
"""A connection with NULL max_query_chars must not crash CAT batching — the
485+
`- 400` headroom subtraction falls back to DEFAULT_MAX_QUERY_CHARS."""
486+
instance = _make_execution_sql()
487+
instance.connection = Connection(sql_flavor="postgresql", max_query_chars=None)
488+
instance.flavor = "postgresql"
489+
instance.flavor_service = get_flavor_service("postgresql")
490+
491+
td = _make_td(measure_expression="m_expr", condition_expression="c_expr")
492+
queries, grouped_defs = instance.aggregate_cat_tests([td], single=True)
493+
494+
assert len(queries) == 1
495+
assert grouped_defs == [[td]]
496+
497+

0 commit comments

Comments
 (0)