You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by hu...@apache.org on 2026/10/15 17:39:41 UTC

(superset) 15/15: test(datasets): drive the NULL-member guard from the query path

This is an automated email from the ASF dual-hosted git repository.

hughhhh pushed a commit to branch hughhhh/pfm-6-explore-indicator
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 394c56a104776cc46c63f6683946fb9d85818f02
Author: Hugh A. Miles II <hu...@gmail.com>
AuthorDate: Thu Oct 15 11:30:33 2026 +0000

    test(datasets): drive the NULL-member guard from the query path
    
    The NULL coverage in this suite was all about a NULL probe *result*; the guard
    that declines an `IN` list carrying a NULL member had no test behind it.
    
    A `None` in the list widens the real predicate to
    `country IS NULL OR country IN ('US')`, so mirroring only the non-null members
    is narrower than the filter and drops rows it keeps. With
    `coalesce(lower(:value), 'unknown')`, mirroring the rest emits
    `region_key IN ('us')` and excludes a row with `country IS NULL,
    region_key = 'unknown'`.
    
    Driven through `get_sqla_query` on the existing mapped-table fixture, with the
    probe booby-trapped rather than stubbed: the decline happens before any
    transform is evaluated, so reaching the warehouse at all is the defect.
    Replacing the guard with the regression it guards against -- dropping the
    `None` and mirroring the rest -- fails here.
    
    Co-Authored-By: Claude Opus 5 (1M context) <no...@anthropic.com>
    Signed-off-by: Hugh A. Miles II <hu...@gmail.com>
---
 .../unit_tests/models/partition_mirroring_test.py  | 39 ++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/tests/unit_tests/models/partition_mirroring_test.py b/tests/unit_tests/models/partition_mirroring_test.py
index e1aa5189fdf..4ead1dd3a3a 100644
--- a/tests/unit_tests/models/partition_mirroring_test.py
+++ b/tests/unit_tests/models/partition_mirroring_test.py
@@ -3110,3 +3110,42 @@ def test_no_inner_mirror_for_main_dttm_which_the_subquery_never_filters(
     # The outer query does filter `main_dttm_col`, so it still prunes.
     assert "dt_epoch >= 1767225600" in outer
     assert "dt_epoch <= 1769904000" in outer
+
+
+def test_a_null_member_of_an_in_list_declines_the_whole_mirror(app: Flask) -> None:
+    """
+    The NULL tests elsewhere cover a NULL *probe result*; this covers a NULL
+    member of the filter's own list, which is a different guard.
+
+    A `None` in an `IN` list widens the real predicate to
+    `country IS NULL OR country IN ('US')`. Mirroring only the non-null members
+    would be *narrower* than that, so the list has to decline entire. With
+    `coalesce(lower(:value), 'unknown')`, mirroring the rest would emit
+    `region_key IN ('us')` and drop a row with `country IS NULL,
+    region_key = 'unknown'` -- a row the original filter keeps.
+
+    The probe is booby-trapped rather than stubbed: the decline happens before
+    any transform is evaluated, so reaching the warehouse at all is the defect.
+    """
+    table = _table(
+        transform="coalesce(lower(:value), 'unknown')",
+        monotonic=False,
+        mapped_column="country",
+        partition_mapped_column="country",
+        partition_column="region_key",
+    )
+
+    with app.app_context():
+        with patch(PROBE, side_effect=AssertionError("the probe must not run")):
+            sql = _query(
+                table,
+                filter=[
+                    {
+                        "col": "country",
+                        "op": FilterOperator.IN.value,
+                        "val": ["US", None],
+                    }
+                ],
+            )
+
+    assert "region_key" not in sql