Skip to content

feat(datasets): mirror filters onto the partition column at query time - #43758

Closed
hughhhh wants to merge 7 commits into
hughhhh/pfm-1-model-migration-apifrom
hughhhh/pfm-2-query-rewrite
Closed

hughhhh wants to merge 7 commits into
hughhhh/pfm-1-model-migration-apifrom
hughhhh/pfm-2-query-rewrite

Conversation

@hughhhh

@hughhhh hughhhh commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Stack (review bottom-up):

  1. feat(datasets): add partition filter mapping model, migration and validation #43757 — model, migration, serialization, validation
  2. feat(datasets): mirror filters onto the partition column at query time #43758 — query rewrite + evaluator
  3. feat(datasets): add partition mapping preview endpoint and editor plumbing #43759 — preview endpoint + editor plumbing
  4. docs: document partition filter mapping #43760 — docs

SUMMARY

Second of four, stacked on the model/migration PR. Reads the mapping and appends an equivalent predicate on the partition column to every query, so chart authors change nothing and queries prune.

Operator safety is the whole of this change. The PRD says "comparison and range operators map directly; IN maps element-wise" — that is not sound in general, and the unsoundness is silent, showing up as wrong chart numbers rather than an error. A mirrored predicate P2 may only be AND-ed onto the query when the original P1 implies it:

Original Safe when
col = v, col IN (…) always — T is a function
col >=, >, <, <=, TEMPORAL_RANGE only if T is monotonic
col != v, NOT IN, LIKE, IS NULL, … never

Negations are never safe because T need not be injective: lower(:value) with country != 'US' mirrors to region_key != 'us', which excludes rows whose country is already lowercase 'us' — rows the original filter keeps.

Monotonicity is declared, not inferred. An earlier draft inferred it from the column type ("a temporal→partition-key transform is monotonic by construction"). That's wrong, and it fails on partition schemes people actually use: hour(:value), date_format(:value, 'dd') and dayofweek(:value) are all reasonable transforms on a TIMESTAMP column and none preserve ordering. Since the Explore time range is a range operator, this is not an edge case. T(lower) <= T(upper) is asserted at runtime as a backstop — necessary, not sufficient, and free because both bounds are already being resolved.

Two things worth reviewer attention:

  1. get_time_filter applied the dataset timezone and legacy hour offset to the bounds internally. That adjustment is extracted into adjust_time_bounds so the mirrored predicate is resolved from the same instants the timestamp predicate compares against. Probing the raw bounds would be wrong by exactly the offset, silently; duplicating the logic would drift.
  2. PARTITION_FILTER_MAPPING must be configured as a static boolean. FEATURE_FLAGS also accepts per-request callables, and since the mapping only enters the cache key when active, a flag resolving per user would let a flag-off user read a cache entry written from pruned SQL by a flag-on user.

Safety posture. Values are bound, never interpolated — they're attacker-controlled in the sense that a Gamma user picks filter values. The probe query references no tables, so it can't leak data or bypass RLS. Any failure at all falls open to no pruning: the query still runs and is still correct, it just scans more partitions.

Deliberate non-coverage, documented in PR 4: filter-value dropdowns (values_for_column builds its own SELECT DISTINCT and never reaches this code path), RLS predicates and extras.where (raw SQL appended downstream of the structured-filter loop), and columns with an active advanced_data_type (translate_filter builds its own predicate shape from translated values, so the (operator, value) pair this reasoning depends on doesn't exist).

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

The mirrored predicate lands in where_clause_and and shows up in View query as an ordinary WHERE clause, by design:

WHERE event_time >= '2026-01-01 00:00:00'
  AND event_time <  '2026-02-01 00:00:00'
  AND dt_epoch   >= 1767225600
  AND dt_epoch   <  1769904000

TESTING INSTRUCTIONS

pytest tests/unit_tests/models/partition_mirroring_test.py \
       tests/unit_tests/connectors/sqla/partition_mapping_test.py

The mirroring tests stub the engine probe and assert on the generated SQL, so they pin down which predicates are emitted and with what values — where the correctness argument lives. Worth reading as the review surface: nothing emitted for !=/NOT IN/LIKE/IS NULL; nothing for a range when the transform isn't declared monotonic; nothing when T(lo) > T(hi); no duplicate when granularity and a TEMPORAL_RANGE filter hit the same column; and the timezone/hour-offset tests, which catch the whole class of off-by-offset bugs.

There is no UI to configure a mapping yet — this is exercised through the ORM.

ADDITIONAL INFORMATION

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

@bito-code-review

bito-code-review Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Branch Excluded

Bito didn't auto-review because the source or target branch is excluded from automatic reviews.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change the branch exclusion settings here, or contact your Bito workspace admin at [email protected].

@netlify

netlify Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7951536
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6abf01711ab7050008d3d7b5
😎 Deploy Preview https://deploy-preview-43758--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.34426% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.74%. Comparing base (b4676ae) to head (74564b9).

Files with missing lines Patch % Lines
superset/connectors/sqla/partition_mapping.py 90.00% 13 Missing and 5 partials ⚠️
superset/models/helpers.py 86.66% 2 Missing and 6 partials ⚠️
Additional details and impacted files
@@                          Coverage Diff                          @@
##           hughhhh/pfm-1-model-migration-api   #43758      +/-   ##
=====================================================================
+ Coverage                              81.72%   81.74%   +0.01%     
=====================================================================
  Files                                   2979     2979              
  Lines                                 181790   182029     +239     
  Branches                               42012    42066      +54     
=====================================================================
+ Hits                                  148575   148794     +219     
- Misses                                 30491    30500       +9     
- Partials                                2724     2735      +11     
Flag Coverage Δ
hive 36.62% <19.26%> (-0.05%) ⬇️
mysql 55.70% <26.22%> (-0.08%) ⬇️
postgres 55.71% <26.22%> (-0.08%) ⬇️
presto 38.53% <23.36%> (-0.05%) ⬇️
python 85.92% <89.34%> (+0.01%) ⬆️
sqlite 55.43% <26.22%> (-0.08%) ⬇️
unit 78.89% <89.34%> (+0.04%) ⬆️

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.

@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from 6f5fb95 to eb2d23b Compare September 4, 2026 21:02
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 3d7615a to 3c96ebe Compare September 4, 2026 21:02
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from eb2d23b to 180fb82 Compare September 4, 2026 21:13
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 3c96ebe to 218eec5 Compare September 4, 2026 21:13
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from 180fb82 to 0ac039d Compare September 5, 2026 02:48
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 218eec5 to 0927c4a Compare September 5, 2026 02:48
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from 0ac039d to b37eefd Compare September 5, 2026 03:06
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 0927c4a to 7ad9986 Compare September 5, 2026 03:06
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from b37eefd to 588f71c Compare September 5, 2026 03:17
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 7ad9986 to d33754b Compare September 5, 2026 03:17
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from 588f71c to d909e49 Compare September 5, 2026 16:10
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from d33754b to 9c5b4a6 Compare September 5, 2026 16:10
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from d909e49 to d092638 Compare September 5, 2026 18:08
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 9c5b4a6 to e14aad3 Compare September 5, 2026 18:08
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from d092638 to f21009f Compare September 5, 2026 18:20
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch 2 times, most recently from c90781e to 21693ee Compare September 5, 2026 20:23
@hughhhh
hughhhh marked this pull request as ready for review September 5, 2026 20:23

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Heya @hughhhh :)

@sadpandajoe's two open threads on helpers.py (NULL/special partition values, and grain-truncated ranges silently dropping rows) look like legit gaps, not nits. Given how much of this PR's own description leans on soundness, I'd want those addressed before this moves forward.

@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from ae07ef6 to 4ffddb3 Compare September 19, 2026 17:58
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 21693ee to 05b7c5c Compare September 19, 2026 17:58
Comment on lines +438 to +446
payload = json.dumps(
[
database.id,
database.backend,
catalog,
schema,
transform,
[repr(value) for value in values],
],

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.

Suggestion: The probe cache key omits connection and session settings, so changing a database URI or timezone can reuse transformed values from the old environment for 24 hours.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Cache

Use CodeAnt Skill Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset/connectors/sqla/partition_mapping.py
**Line:** 438:446
**Comment:**
	*Cache: The probe cache key omits connection and session settings, so changing a database URI or timezone can reuse transformed values from the old environment for 24 hours.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 3d24984.

The cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on along with the database identity, preventing reuse across connection or session-setting changes.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of da9f21c.

The cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on alongside the transform inputs, invalidating entries when connection or session settings change.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 766673e.

The probe cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on in addition to the database identity, so URI, session settings, and other database edits invalidate prior entries.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of ea00aa4.

The probe cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on in addition to the database identity, so URI, session settings, and other database edits invalidate prior entries.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 3c07046.

The probe cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on in addition to the database identity, so URI, session settings, and other database edits invalidate prior entries.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 73b753c.

The probe cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on in addition to the database identity, so URI, session settings, and other database edits invalidate prior entries.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 3d028a0.

The probe cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on in addition to the database identity, so URI, session settings, and other database edits invalidate prior entries.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 74564b9.

The probe cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on in addition to the database identity, so URI, session settings, and other database edits invalidate prior entries.

If that's not right, unresolve this thread and CodeAnt will leave it open.

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.

✅ CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved as of 7951536.

The cache key now includes database.sqlalchemy_uri, database.extra, and database.changed_on alongside the database identity and backend, preventing reuse across connection or session-setting changes.

If that's not right, unresolve this thread and CodeAnt will leave it open.

@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 3d24984 to 3561db1 Compare September 21, 2026 21:37
@github-actions github-actions Bot added requires:rebase Requires rebasing on top of current master and removed requires:rebase Requires rebasing on top of current master labels Sep 22, 2026
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from 9289071 to dbd8371 Compare September 26, 2026 23:35
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from ea00aa4 to 24e44a0 Compare September 26, 2026 23:35
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from 56a68c0 to c10ad3e Compare September 29, 2026 16:31
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch 2 times, most recently from 3c07046 to 73b753c Compare September 29, 2026 18:10
hughhhh and others added 4 commits October 1, 2026 09:23
Second of four. Reads the mapping added by the previous PR and appends an
equivalent predicate on the partition column to every query, so chart authors
change nothing and queries prune.

Operator safety is the whole of this change. The PRD says "comparison and range
operators map directly; IN maps element-wise", and that is not sound in
general -- the unsoundness is silent, showing up as wrong chart numbers rather
than an error. A mirrored predicate may only be AND-ed on when the original
implies it:

  `=` and `IN`                        always -- T is a function
  ranges and TEMPORAL_RANGE           only when T preserves ordering
  negations, LIKE, IS NULL, ...       never

Negations are never safe because T need not be injective: `lower(:value)` with
`country != 'US'` mirrors to `region_key != 'us'`, which excludes rows whose
country is already lowercase 'us' -- rows the original filter keeps.

Monotonicity is a property of the transform, not of the column's data type.
`hour(:value)`, `date_format(:value, 'dd')` and `dayofweek(:value)` are all
reasonable transforms on a TIMESTAMP column and none preserve ordering, so it
is declared by the owner rather than inferred. `T(lower) <= T(upper)` is
asserted at runtime as a backstop -- necessary, not sufficient, and free
because both bounds are already being resolved.

The transform is resolved against the engine and emitted as a literal, so
"View query" shows an ordinary WHERE clause. Values are bound, never
interpolated: they are attacker-controlled in the sense that a Gamma user picks
filter values. Any failure at all falls open to no pruning -- the query still
runs and is still correct, it just scans more partitions.

Two things worth flagging for review:

`get_time_filter` applied the dataset timezone and legacy hour offset to the
bounds internally. That adjustment is extracted into `adjust_time_bounds` so
the mirrored predicate is resolved from the *same* instants the timestamp
predicate compares against. Probing the raw bounds would be wrong by exactly
the offset, silently, and duplicating the logic would drift.

`PARTITION_FILTER_MAPPING` must be configured as a static boolean. FEATURE_FLAGS
also accepts per-request callables, and since the mapping only enters the cache
key when active, a flag that resolved per user would let a flag-off user read a
cache entry written from pruned SQL by a flag-on user.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A mirrored predicate stands in for a real one, so it may only ever be
wider. Two cases made it narrower and silently dropped rows.

A grain makes the real predicate compare the truncated column, while the
mirror used the raw value. Drill-to-detail sends the clicked bucket as
`==` plus the chart's grain, so `DATE_TRUNC('week', event_time) = X`
mirrored to `dt_epoch = T(X)` and kept only the rows at the bucket's first
instant. A grained range has the same flaw at its upper bound: a row in
the final partial bucket satisfies `DATE_TRUNC(...) < until` while the raw
bound excludes it. Neither bound is recoverable here -- "week ending
Saturday" rounds forward, and TIME_GRAIN_ADDONS are arbitrary SQL -- so
filters carrying a grain no longer mirror. Only drill queries carry one;
ordinary charts keep pruning.

A comparison against a NULL partition value is NULL, so a row in a NULL
partition was dropped even when the real filter matched it: Hive and
Impala's default partition, or a transform returning NULL for an input it
cannot convert. The mirror now admits NULL partitions, which keeps those
rows and still prunes, at one extra partition read.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The probe asks a specific database to evaluate the transform, so the
answer belongs to that connection, but the cache key carried only
`database.id`. That survives an edit to the URI or to `extra` -- a session
timezone, say -- so values computed against the old environment were
reused for the whole timeout, and a wrong transformed bound prunes away
rows the real filter keeps.

Add the URI and `extra` to the key, plus `changed_on` for the edits that
do not appear in either, such as a rotated password.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A grained range compares the truncated column, so the raw bounds it carries do
not describe the rows it keeps: a row in the final partial bucket satisfies
`trunc(col) < until` while `col < until` excludes it. That case previously
skipped mirroring altogether, which is safe but gives up pruning on exactly the
queries that scan the most -- drill-to-detail.

Widening recovers it. The obvious floor-based version would be wrong: which way
a grain rounds is not knowable from its duration, and shipped specs disagree --
`WEEK_ENDING_SATURDAY` is `date_add(col, 6-dow)` on Hive and `date_trunc(...) +
interval '5' day` on Presto, both forward, while Ocient's grains are `ROUND`,
i.e. to nearest. Widening only the upper bound would drop up to a week of rows
off the bottom of a week-ending range.

What every grain does satisfy is `|trunc(ts) - ts| < width(grain)`, so widening
*both* bounds by one bucket is no narrower than the real predicate whichever way
it rounds -- and it needs no monotonicity of `trunc` itself, which is what
rescues Hive's oddly-anchored `P1W`. Width is a property of the grain, not the
engine, so `grain_bucket_width` is one literal table rather than a per-engine
matrix nobody could keep current.

The widened upper bound is `<=` rather than `<`: `ts < until + width` only gives
`T(ts) <= T(until + width)` for a transform that is monotonic but not strictly
so, such as `unix_timestamp` on a sub-second column. This also closes that gap
on the ungrained path, where a strict `<` was already slightly optimistic.

Widths are written out rather than parsed -- four week grains are ISO intervals
with an anchor that `parse_duration` rejects, and `PT0.5H`/`P0.25Y` are
fractional -- and held as `relativedelta` so `P1M` stays calendar arithmetic.
Grains an operator supplied have no width we can claim to know: both
`TIME_GRAIN_ADDONS` and a per-engine `TIME_GRAIN_ADDON_EXPRESSIONS` override of
a built-in duration fall back to not mirroring.

Scope is `TEMPORAL_RANGE`. Grained `==` would have to become a two-sided range,
needing a monotonic transform that `EQUALS` does not require today; grained `IN`
would need a union of buckets the AND-ed sink cannot express. Both stay deferred,
and the comment there now says so rather than reading as unsafe in principle.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@hughhhh
hughhhh force-pushed the hughhhh/pfm-1-model-migration-api branch from f191e0b to ae33f9f Compare October 1, 2026 17:10
@hughhhh
hughhhh force-pushed the hughhhh/pfm-2-query-rewrite branch from 73b753c to 3d028a0 Compare October 1, 2026 17:10
hughhhh and others added 3 commits October 1, 2026 16:29
Three review findings on the query-rewrite PR, and the flag description that
this PR makes stale.

`_transform_is_usable` restated a subset of `validate_transform`: blank,
placeholder, Jinja, parseable -- but not the non-deterministic denylist. Since
create and import do not validate a mapping at all, a transform calling `now()`
or `rand()` could reach storage, be treated as usable here, and mirror a filter
with a value frozen at whatever moment the probe ran. Meanwhile
`is_transform_active` -- which drives the Explore indicator and *does* run that
check -- reported the mapping inactive, so there was no signal anywhere that
mirroring was happening with a non-deterministic value. Deleted in favour of
`is_transform_active` itself. Two statements of one rule is one too many.

`is_parseable`'s docstring claimed "a single select expression" and did not check
it. `SELECT lower(:value), 'x'` parses exactly as well as `SELECT lower(:value)`
but returns two columns per input, and the probe reads one column per input: for
a two-value `IN` filter it took columns 0 and 1, which are the two *expressions*
of the first value, so the second value's partition vanished from the predicate
and its rows were excluded. Now rejected at validation time, via a new
`SQLStatement.count_select_expressions`.

The probe's own guard was `len(row) < len(distinct)`, which only caught the
harmless direction. 2N columns for N inputs sailed through it and produced the
misaligned read above, so it is now `!=` -- a backstop for a transform stored
before the validation existed.

The probe also built a bare `SELECT <expr>` with no `FROM`, which Oracle and Db2
reject. `_run_probe` swallows the error, so the only symptom was a correctly
configured mapping that silently never pruned. `select_without_from_suffix` on
the engine spec supplies `FROM DUAL` / `FROM SYSIBM.SYSDUMMY1` where they are
needed and nothing where they are not.

Finally, `PARTITION_FILTER_MAPPING`'s description still said no query consumer
emits the mirrored predicate. This is the PR that makes that false.
`docs/static/feature-flags.json` is regenerated from it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added the doc Namespace | Anything related to documentation label Oct 2, 2026
@hughhhh
hughhhh removed this pull request from stack #43893 October 2, 2026 01:22
@hughhhh hughhhh mentioned this pull request Oct 2, 2026
7 of 9 tasks
@hughhhh

hughhhh commented Oct 2, 2026

Copy link
Copy Markdown
Member Author

Closing in favour of #43870, which now carries the whole feature against master rather than the five-PR stack this was the query-time rewrite of.

Nothing is lost. The commits are unchanged and still in #43870's history, so this stage is still reviewable on its own, and the 2 unresolved comments from this PR are reproduced in an inventory comment there — each with a link back to the original thread and the commit that addressed it. They were all addressed in the review pass of 2026-10-01; they show as unresolved here only because the threads were never clicked shut.

@sadpandajoe @rusackas — sorry for the churn. If you would rather keep reviewing stage by stage, say so and I will reopen; the branches are all still there.

@hughhhh hughhhh closed this Oct 2, 2026
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/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants