Repository navigation
fix(semantic-layer): keep NULL rows in user exclusion filters - #46377
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #46377 +/- ##
===========================================
+ Coverage 65.68% 85.73% +20.05%
===========================================
Files 3120 3114 -6
Lines 216320 215793 -527
Branches 51293 51067 -226
===========================================
+ Hits 142082 185020 +42938
+ Misses 70982 27358 -43624
- Partials 3256 3415 +159
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aminghadersohi
left a comment
There was a problem hiding this comment.
Exclusions now keep NULL rows like datasets; the provider contract still describes the old leaf shapes, and two new test lines fail full-tree mypy.
gabotorresruiz
left a comment
There was a problem hiding this comment.
Hi @mikebridge, thanks for this fix. Approving: for all four operators the filter the mapper emits keeps the same rows an ordinary dataset keeps on Postgres, and explicit NULL exclusion, empty lists and != NULL are unchanged. Only the query's own filters reach the rewrite; guest RLS on a semantic view is refused before the provider is called, same as before. @aminghadersohi's two typing suggestions reproduce for me (clean in the scoped mypy run, two errors once the superset-core sources are in it), so they are worth committing before merge. I left two non-blocking notes inline. CI is green.
| literal SQL semantics. A provider that does not support an operator continues | ||
| to refuse it as before. |
There was a problem hiding this comment.
Not a blocker, and +1 to @aminghadersohi's note below on the provider contract. One measured case for this sentence: a provider that accepts != or NOT IN as a leaf but rejects groups goes from answering to refusing. The in-repo E2E stub (tests/e2e_extensions/semantic_stub) is one, since it rejects every OrFilter: both filters return 200 before this change and 400 with it. Could we add an UPDATING.md line, like the earlier semantic NULL filter change and the dataset != / NOT LIKE change both got, and teach the stub groups here or in a follow-up?
There was a problem hiding this comment.
Added the UPDATING.md compatibility line in a0e416c.
You're right that the stub rejects every OR group. Teaching it grouped predicates is left as a separate follow-up rather than changing provider execution in this docs/test patch.
| "user_id": get_user_id(), | ||
| "source_rls": source_rls, | ||
| "semantic_filter_protocol": "semantic-null-filters-v1", | ||
| "semantic_filter_protocol": "semantic-null-filters-v2", |
There was a problem hiding this comment.
Not a blocker, and I might be missing the intent. semantic_filter_protocol goes into the annotation context for every datasource, so this bump also rotates the key of ordinary dataset charts that carry an annotation layer. I checked a SqlaTable chart: with a native annotation layer its key changes with this PR, and without a layer it stays the same. The body and the docs scope the one-time rebuild to semantic views. Worth saying so there, or should the field only be added when a source is a SemanticView?
There was a problem hiding this comment.
You're right: the annotation context includes the marker for ordinary datasets too, so a dataset chart with a native annotation layer also gets a one-time rebuild. The docs now say so in a0e416c; cache-key behavior itself is unchanged by the follow-up.
gabotorresruiz
left a comment
There was a problem hiding this comment.
Hi @mikebridge, thanks for the follow-up. a0e416ce covers both of my notes: the UPDATING.md line is in, and the docs now say dataset charts with an annotation layer rebuild their cache once. Apart from that commit, the merge from master leaves the diff unchanged, and CI is green at this head. Still LGTM.
|
@msyavuz @geido @rusackas @sadpandajoe this PR includes a small edit to |
…e-keeps-null # Conflicts: # UPDATING.md
SUMMARY
User-visible after deploy: exclude (NOT IN), not-equal, NOT LIKE and NOT ILIKE filters on semantic views keep rows where the value is empty, matching datasets.
User-visible after deploy: cached chart results for semantic views are rebuilt once after deploy. Ordinary dataset charts that carry a native annotation layer also get a one-time rebuild, because the annotation cache context includes the same protocol marker; dataset charts without an annotation layer keep their cached results. Providers that accept an exclusion as a leaf but reject OR groups will now refuse these filters; see UPDATING.md.
Background: ordinary dataset chart and dashboard exclude (
NOT IN) filters compensate for SQL NULL semantics. Semantic-view filters previously passed a plain NOT IN leaf, leaving NULL retention to the provider. SQL-style NOT IN drops missing values even when the user has not selected them for exclusion; providers that already retained them may see no result change.Changes: normalize nonempty user NOT IN without NULL, non-NULL !=, NOT LIKE and NOT ILIKE into the existing OR group with IS_NULL. Explicit NULL exclusion, empty membership lists and SDK leaf/literal SQL semantics remain unchanged. The normalized query changes the semantic result-cache identity; a separate chart-data protocol bump isolates old/new chart results, including during rolling deployments.
A provider that does not support an operator continues to refuse it as before.
The extension-point documentation note has moved to #46447 for separate code-owner review.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
For rows CORP, RETAIL and NULL, a provider using SQL-style NOT IN previously retained only RETAIL when excluding CORP; it retains RETAIL and NULL after this change. Excluding CORP and NULL still retains only RETAIL. No UI layout changes.
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION