sadpandajoe commented on code in PR #45904:
URL: https://github.com/apache/superset/pull/45904#discussion_r4447098995


##########
tests/unit_tests/semantic_layers/cache_policy_test.py:
##########
@@ -188,6 +188,103 @@ def test_filter_implication_matrix(
     assert cache_policy.implies(new_filter, cached_filter) is expected
 
 
[email protected](
+    "new_filter,cached_filter,expected",
+    [
+        # Empty IN is FALSE, so it proves every cached predicate it is 
compared to.
+        (
+            where(COUNTRY, Operator.IN, frozenset()),
+            where(COUNTRY, Operator.IN, frozenset({"GB"})),
+            True,
+        ),
+        (
+            where(COUNTRY, Operator.IN, frozenset()),
+            where(COUNTRY, Operator.IS_NOT_NULL, None),
+            True,
+        ),
+        # Empty NOT IN is TRUE for NULL rows too, so it proves no narrower 
cache.
+        (
+            where(COUNTRY, Operator.NOT_IN, frozenset()),
+            where(COUNTRY, Operator.IS_NOT_NULL, None),
+            False,
+        ),
+        (
+            where(COUNTRY, Operator.NOT_IN, frozenset()),
+            where(COUNTRY, Operator.NOT_IN, frozenset()),
+            True,
+        ),
+    ],
+)
+def test_empty_membership_implication(
+    new_filter: Filter,
+    cached_filter: Filter,
+    expected: bool,
+) -> None:
+    assert cache_policy.implies(new_filter, cached_filter) is expected
+
+
[email protected](
+    "operator,expected_countries,expected_revenue",
+    [
+        (Operator.IN, None, [None]),

Review Comment:
   The empty-input rollup is only exercised here for SUM and COUNT, which take 
the callable branch of `_rollup`; MIN and MAX still go through 
`frame[name].agg("min"/"max")`, and the existing MIN/MAX rollup tests in 
`cache_transform_test.py` only use nonempty input. If an empty IN filter leaves 
no cached rows and the query asks for an ungrouped MIN or MAX, a change that 
returns zero rows or fails on the empty Arrow-backed series would pass this 
suite while SQL returns one row of NULL. Could this case add a MIN and a MAX 
metric (or a sibling case) and assert the ungrouped empty-IN result is exactly 
one row with typed NULLs?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

  • [PR] fix(se... mikebridge (via GitHub) via notifications
    • Re: [P... netlify[bot] (via GitHub) via notifications
    • Re: [P... codecov[bot] (via GitHub) via notifications
    • Re: [P... mikebridge (via GitHub) via notifications
    • Re: [P... sadpandajoe (via GitHub) via notifications
    • Re: [P... mikebridge (via GitHub) via notifications
    • Re: [P... sadpandajoe (via GitHub) via notifications
    • Re: [P... sadpandajoe (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... mikebridge (via GitHub) via notifications
    • Re: [P... mikebridge (via GitHub) via notifications

Reply via email to