From 8bb3082ffdc804efc25f093bc53257e1b0d8a436 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 18 May 2026 16:14:34 -0500 Subject: [PATCH] test(datasets): strengthen #25839 guard to verify downstream SQL is rendered Per @codeant-ai's review: the previous assertion only verified that process_template was called with the raw SQL. A regression that renders Jinja for sqlglot parsing but then passes the original raw SQL to get_columns_description would still produce the user-visible bug while slipping past the test. Now also asserts get_columns_description received the rendered SQL string. Co-Authored-By: Claude Sonnet 4.6 --- tests/unit_tests/connectors/sqla/utils_test.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/unit_tests/connectors/sqla/utils_test.py b/tests/unit_tests/connectors/sqla/utils_test.py index f40934289f1..6c6f5e38926 100644 --- a/tests/unit_tests/connectors/sqla/utils_test.py +++ b/tests/unit_tests/connectors/sqla/utils_test.py @@ -146,7 +146,7 @@ def test_get_virtual_table_metadata_renders_jinja(mocker: MockerFixture) -> None error (the user-visible symptom is "Invalid SQL" when clicking "SYNC COLUMNS FROM SOURCE" on a dataset that uses {{ from_dttm }} etc.). """ - mocker.patch( + mock_get_columns_description = mocker.patch( "superset.connectors.sqla.utils.get_columns_description", return_value=[{"name": "rendered_col", "type": "INTEGER"}], ) @@ -172,3 +172,16 @@ def test_get_virtual_table_metadata_renders_jinja(mocker: MockerFixture) -> None dataset.get_template_processor().process_template.assert_any_call( raw_sql, **dataset.template_params_dict ) + + # End-to-end guard: the rendered SQL must reach get_columns_description, + # not the raw Jinja string. A regression where rendering is used for + # parsing only and the raw SQL leaks downstream would pass the + # process_template assertion above but fail this one. + call_args = mock_get_columns_description.call_args + assert call_args is not None, "get_columns_description was never called" + passed_query = call_args.kwargs.get("query") + if passed_query is None and call_args.args: + passed_query = call_args.args[-1] + assert passed_query == rendered_sql, ( + f"get_columns_description received unrendered SQL: {passed_query!r}" + )