Skip to content

fix(semantic-layer): keep NULL rows in user exclusion filters - #46377

Merged
mikebridge merged 8 commits into
apache:masterfrom
mikebridge:fix-semantic-exclude-keeps-null
Nov 21, 2026
Merged

mikebridge merged 8 commits into
apache:masterfrom
mikebridge:fix-semantic-exclude-keeps-null

Conversation

@mikebridge

@mikebridge mikebridge commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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

  • Initial NOT IN regression: eight failures before the fix; the follow-up operators produced 26 failures before their fix, including empty patterns and cache identity.
  • The chart-data cache regression failed for all three producer-version cases before the protocol bump; it compares the exclusion query's key against the old protocol key.
  • Verify chart adhoc and dashboard native exclusion against a dimension containing missing values; select NULL explicitly to exclude missing rows.
  • Provider serializer probes cover grouped not-equal and NOT LIKE, plus NOT ILIKE serialization or its unchanged refusal. No live provider execution is claimed.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags: SEMANTIC_LAYERS
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API

@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Nov 19, 2026
@mikebridge
mikebridge marked this pull request as ready for review November 19, 2026 19:04
@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 588a21618e09

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.73%. Comparing base (552711f) to head (588a216).
⚠️ Report is 8 commits behind head on master.

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     
Flag Coverage Δ
hive 33.92% <14.28%> (-0.01%) ⬇️
mysql 51.56% <14.28%> (?)
postgres 51.59% <14.28%> (-0.01%) ⬇️
presto 35.60% <14.28%> (-0.01%) ⬇️
python 88.38% <100.00%> (+36.55%) ⬆️
sqlite 51.26% <14.28%> (-0.01%) ⬇️
unit 83.78% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aminghadersohi aminghadersohi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +139 to +140
literal SQL semantics. A provider that does not support an operator continues
to refuse it as before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 gabotorresruiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mikebridge

Copy link
Copy Markdown
Member Author

@msyavuz @geido @rusackas @sadpandajoe this PR includes a small edit to docs/developer_docs/extensions/extension-points/semantic-layers.md, so it needs an approval from a code owner of that folder before it can merge. It is otherwise approved and green. Could one of you take a look when you have a moment? Thanks!

@mikebridge
mikebridge merged commit 4e37ad0 into apache:master Nov 21, 2026
74 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Namespace | Anything related to documentation size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants