Skip to content

feat(datasets): partition filter mapping - #43870

Merged
hughhhh merged 218 commits into
masterfrom
hughhhh/pfm-6-explore-indicator
Oct 27, 2026
Merged

hughhhh merged 218 commits into
masterfrom
hughhhh/pfm-6-explore-indicator

Conversation

@hughhhh

@hughhhh hughhhh commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

Adds partition filter mapping: a dataset owner names one partition column and one business column whose filters are mirrored onto it, and every query then carries an equivalent predicate on the partition column, so chart authors change nothing and queries prune. Behind PARTITION_FILTER_MAPPING, off by default.

Datasets on Hadoop-family engines are commonly partitioned on a technical column — an epoch integer, a lowercased region key — that no analyst would filter on. Unless a query carries a predicate on that column the engine scans every partition, and the only workaround today is hand-writing the predicate as custom SQL in a virtual dataset, which pushes a performance concern onto every chart author and takes the dataset out of the physical/syncable path.

This PR replaces a five-PR stack. It was #43757 → #43758 → #43759 → #43891 → #43870, with the docs in #43760; all are now closed in favour of this one, as is #44816, which consolidated the backend half against a tables.extra storage interface rather than a migration. The commit history is unchanged, so each stage is still reviewable on its own: use the commit list, or the per-stage compare links in the closed PRs. Every unresolved review comment from the closed PRs has been carried forward — see the comment below for the inventory and what became of each.

Storage

Four columns, following the always_filter_main_dttm / currency_code_column precedent for "a dataset-level setting that names a column":

Column Purpose
tables.partition_column the physical partition column
tables.partition_mapped_column explicit override; NULL follows main_dttm_col
table_columns.partition_value_transform the :value expression
table_columns.partition_transform_is_monotonic gates range mirroring

The effective mapped column is partition_mapped_column or main_dttm_col, so "re-pointing the default datetime column moves the mapping with it, unless overridden" falls out of the model rather than needing code. A JSON blob inside tables.extra was considered and rejected: extra is a user-editable free-text box, buildExtraJsonObject rebuilds column.extra from a hardcoded key list on every save, and there is no validation layer for it. (#44816 explored that route and is closed; if the migration is the blocker, that is the conversation to reopen, not this storage choice.)

Operator safety is the heart of the query rewrite

A mirrored predicate P2 may only be AND-ed onto a query when the original P1 implies it. Getting this wrong is silent — it shows up as wrong chart numbers, not an error.

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', excluding 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; that is wrong on partition schemes people actually use — hour(:value), date_format(:value, 'dd') and dayofweek(:value) are all reasonable transforms on a TIMESTAMP and none preserve ordering. T(lower) <= T(upper) is asserted at runtime as a backstop.

Three more properties the rewrite holds to:

  • The mirror may only ever be wider than the filter it stands in for. A comparison against a NULL partition value is NULL, so the emitted clause is (preds) OR partition_col IS NULL — Hive and Impala park rows with a NULL key in __HIVE_DEFAULT_PARTITION__, and those rows must survive. A grained range compares the truncated column, so its raw bounds do not describe the rows it keeps; those mirror by widening both bounds one bucket, and grained =/IN do not mirror at all.
  • Bounds are resolved from the same instants the timestamp predicate compares against. get_time_filter applied the dataset timezone and legacy hour offset internally; that is extracted into adjust_time_bounds rather than duplicated.
  • Everything fails open. Any failure at all means no pruning: the query still runs and is still correct, it just scans more partitions.

PARTITION_FILTER_MAPPING must be 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.

The dataset editor

A Partition column select in the Columns tab's Default Column Settings, plus a read-only computed Maps to partition — deliberately not a peer dropdown, since it reflects partition_mapped_column ?? main_dttm_col and a second select would let it drift silently. The partition column's row is muted, carries a PARTITION tag, and defaults Is filterable / Is dimension off. A Partition filter mapping section in the row expand has three states: the mapped column holds the transform, every other column offers to take the mapping over, the partition column itself shows nothing.

A live Preview panel shows sample input → emitted predicate, backed by POST /api/v1/dataset/<pk>/partition_mapping/preview/:

{ "mapped_column": "event_time",
  "value_transform": "unix_timestamp(:value)",
  "sample_values": ["2026-01-15 00:00:00"] }
→ { "valid": true, "emitted_predicate": "dt_epoch = 1768435200 OR dt_epoch IS NULL" }

It fires a real warehouse query from a text input, so the order of its guards is the point: validation and the stored-expression policy run before anything reaches the engine (so a half-typed transform costs zero queries, and a transform cannot smuggle a subquery past the gate that governs every other stored expression); it shares the evaluator and probe cache with the query path, so preview and runtime cannot drift; and it is rate-limited per user and dataset in a fixed window, because client debouncing is a courtesy, not a guard.

Two places the spec and the backend disagreed, resolved in the UI's favour:

  1. The mockups have no monotonicity control, but the query path only mirrors ranges when the transform is declared order-preserving — so the headline example (a time range producing two dt_epoch bounds) was unreachable. Hence Transform preserves ordering.
  2. The PRD asks for unix_timestamp(:value) as the temporal default, but that is Hive syntax and would not parse on Postgres, Trino or BigQuery. The default moves to the engine spec (partition_value_transform_default); engines without one offer no pre-fill rather than a wrong one.

The Explore indicator

A small glyph on any filter whose column the dataset mirrors, with the tooltip "This filter is also applied to a partition column for faster queries. See 'View query' for the generated SQL." Chart authors configure nothing and ideally never learn the word "partition"; the indicator exists only to explain the speed-up and point at the SQL.

It shows only where the query path really does mirror — it checks the operator against the set the server computes from declared monotonicity, and excludes grained filters, the <NULL> sentinel, and a time range with no temporal column selected. The one gap is deliberate and commented: a virtual dataset's Jinja get_filters(..., remove_filter=True) makes the backend skip both the filter and its mirror, but removed_filters is built during query generation and is not in form_data, so the browser cannot know. The glyph is advisory; "View query" is the authority.

partitionColumn already exists on these components as the unrelated Presto latest_partition feature, so the prop is partitionMapping throughout — two meanings of one word, one prop apart, is not worth the saving.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

See the screenshots on the closed PRs, which remain valid: the editor controls and preview panel on #43891, and the indicator on #43870 — 02-adhoc-operator-matrix.png there is the clearest single frame, one chart carrying eight filters with the glyph on exactly the two that mirror.

TESTING INSTRUCTIONS

pytest tests/unit_tests/connectors/sqla/partition_mapping_test.py \
       tests/unit_tests/models/partition_mirroring_test.py \
       tests/unit_tests/datasets/partition_mapping_preview_test.py \
       tests/unit_tests/datasets/partition_mapping_serialization_test.py \
       tests/unit_tests/dao/dataset_test.py \
       tests/unit_tests/commands/dataset/ \
       tests/unit_tests/datasets/commands/importers/v1/import_test.py \
       tests/unit_tests/sql/parse_tests.py

cd superset-frontend && npm run test -- \
  src/components/Datasource \
  src/explore/components/PartitionPruningIndicator \
  packages/superset-ui-chart-controls/test/shared-controls

Manual, in a dev stack with PARTITION_FILTER_MAPPING: True, against a physical table partitioned on a technical column:

  1. Open the dataset editor → Columns → Default Column Settings, pick the partition column. Confirm its row mutes, takes a PARTITION tag, and drops out of Explore's dimension and filter pickers.
  2. Expand the mapped column's row, type a transform, and watch the preview render the emitted predicate. Try a broken one (unix_timestamp(:value) and confirm it reports a parse error without hitting the warehouse.
  3. Save, build a chart with a time range and a filter on the mapped column, and confirm the glyph appears on both — then check "View query" for the extra predicate on the partition column.
  4. Set a filter the matrix forbids (!= on the mapped column) and confirm no glyph and no mirrored predicate.

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)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided — four ADD COLUMNs with no backfill and no index, plus the matching Continuum shadow columns so dataset version history and restore keep working; effectively instant on Postgres/MySQL, no downtime expected
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review

bito-code-review Bot commented Sep 4, 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 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 83572e7
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ae110e056b4fc180f19d8ad
😎 Deploy Preview https://deploy-preview-43870--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.

@sadpandajoe
sadpandajoe requested a review from eschutho September 4, 2026 17:27
@hughhhh
hughhhh changed the base branch from hughhhh/pfm-5-editor-ui to master September 4, 2026 19:22
@hughhhh
hughhhh changed the base branch from master to hughhhh/pfm-5-editor-ui September 4, 2026 19:23
@hughhhh
hughhhh force-pushed the hughhhh/pfm-6-explore-indicator branch from 949b0af to 413e5c6 Compare September 4, 2026 19:54
@hughhhh
hughhhh force-pushed the hughhhh/pfm-5-editor-ui branch from e51df8a to 240191d Compare September 4, 2026 21:03
@hughhhh
hughhhh force-pushed the hughhhh/pfm-6-explore-indicator branch from 413e5c6 to 6142a9e Compare September 4, 2026 21:03
@hughhhh
hughhhh force-pushed the hughhhh/pfm-5-editor-ui branch from 240191d to de8d5b7 Compare September 4, 2026 21:13
@hughhhh
hughhhh force-pushed the hughhhh/pfm-6-explore-indicator branch from 6142a9e to eeb4218 Compare September 4, 2026 21:13
@hughhhh
hughhhh force-pushed the hughhhh/pfm-5-editor-ui branch from de8d5b7 to 42d68c0 Compare September 5, 2026 02:49
@hughhhh
hughhhh force-pushed the hughhhh/pfm-6-explore-indicator branch from eeb4218 to 2e57d43 Compare September 5, 2026 02:49
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct: the PartitionPruningIndicator was being rendered in OptionControlLabel without verifying if the filter is actually active or applicable to the current context.

To resolve this, you should ensure the indicator only renders when the partitionMapping is valid and active. Since OptionControlLabel already receives partitionMapping as a prop, you can update the component to check for its existence before rendering the indicator.

Proposed Fix

Update superset-frontend/src/explore/components/controls/OptionControls/index.tsx to conditionally render the indicator:

// In OptionControlLabel component
{partitionMapping?.active && (
  <PartitionPruningIndicator mapping={partitionMapping} />
)}

This ensures the glyph only appears when the mapping is active, preventing misleading indicators for inactive or unrelated filters.

Would you like me to fetch all other comments on this PR to validate and implement fixes for them as well?

superset-frontend/src/explore/components/controls/OptionControls/index.tsx

<PartitionPruningIndicator mapping={partitionMapping} />

@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.72666% with 84 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.53%. Comparing base (887e51b) to head (d18087b).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
superset/models/helpers.py 89.11% 15 Missing and 12 partials ⚠️
...e/components/DatasourceEditor/DatasourceEditor.tsx 85.27% 19 Missing ⚠️
...onfigModal/FiltersConfigForm/FiltersConfigForm.tsx 54.16% 11 Missing ⚠️
superset/commands/dataset/create.py 83.33% 2 Missing and 2 partials ⚠️
superset/commands/dataset/importers/v0.py 92.30% 2 Missing and 2 partials ⚠️
superset/commands/dataset/update.py 90.47% 2 Missing and 2 partials ⚠️
superset/datasets/api.py 90.47% 3 Missing and 1 partial ⚠️
...rtitionFilterMapping/usePartitionMappingPreview.ts 94.33% 3 Missing ⚠️
superset/commands/dataset/columns/delete.py 71.42% 0 Missing and 2 partials ⚠️
superset/commands/dataset/importers/v1/utils.py 95.55% 1 Missing and 1 partial ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #43870      +/-   ##
==========================================
+ Coverage   84.44%   84.53%   +0.09%     
==========================================
  Files        3059     3067       +8     
  Lines      202769   204894    +2125     
  Branches    47512    48128     +616     
==========================================
+ Hits       171223   173217    +1994     
- Misses      28289    28376      +87     
- Partials     3257     3301      +44     
Flag Coverage Δ
hive 34.55% <21.81%> (-0.20%) ⬇️
javascript 80.72% <94.43%> (+0.11%) ⬆️
mysql 52.48% <39.46%> (-0.32%) ⬇️
postgres 52.49% <39.46%> (-0.32%) ⬇️
presto 36.28% <24.03%> (-0.21%) ⬇️
python 87.62% <93.02%> (+0.06%) ⬆️
sqlite 52.25% <39.46%> (-0.32%) ⬇️
unit 82.28% <92.87%> (+0.19%) ⬆️

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-5-editor-ui branch from 42d68c0 to 0118629 Compare September 5, 2026 03:06
@hughhhh
hughhhh force-pushed the hughhhh/pfm-6-explore-indicator branch from 2e57d43 to 6132109 Compare September 5, 2026 03:06
@hughhhh
hughhhh force-pushed the hughhhh/pfm-5-editor-ui branch from 0118629 to e68a360 Compare September 5, 2026 03:17
@hughhhh
hughhhh force-pushed the hughhhh/pfm-6-explore-indicator branch from 6132109 to 63316d4 Compare September 5, 2026 03:17
hughhhh and others added 4 commits October 23, 2026 16:03
…migration

The popover test added in #44843 asserted that a config stored under the
display alias `Time` is ignored. #44955 deliberately reads legacy
`Time`-keyed configs and migrates them onto `__timestamp`, so the
assertion is stale. Assert the intended behaviour instead: the legacy
config is read back and an edit is saved under `__timestamp`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 34d5617)
…er range

- An Oracle DATE keeps the time of day, but Superset maps it to sa.Date, so
  the days-only exemption in the temporal literal path skipped the
  precision check and wrote 06:30 as TO_DATE('2026-01-12', 'YYYY-MM-DD').
  Whether a key holds only days is now read from the database's own
  dialect, which makes Oracle's DATE a DateTime; the mirror is declined
  where the literal would drop the time, and an exact midnight still
  mirrors.
- A chart hands the transform a temporal value as text (simple filters) or
  as a datetime the dialect writes as a typed literal (time ranges). The
  preview probed only the text, so TO_DATE(:value, fmt) previewed valid on
  Oracle while every time range landed in year 0012. A temporal sample is
  now previewed as a time range sends it, the text shape is probed too, and
  the preview refuses a transform whose two answers differ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hard

Each case mounts the whole dataset modal, edits two collections and saves.
That takes about 8s locally, the same on this branch and on master, but it
crossed the global 20s testTimeout on loaded CI shards. Raise it for this
file to 60s, as other heavy modal suites do with jest.setTimeout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
):
# The format is unreachable in `dttm_sql_literal` for this column,
# so reproducing it here would describe a different bound.
return dttm

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.

When the engine answers convert_dttm for a DATE column, the filter compares against the date-only literal ('2026-01-01' on SQLite), but this returns the widened datetime, which the probe binds as '2026-01-01 00:00:00.000000'. With a DATE column event_date, a text partition key p = CAST(event_date AS TEXT) and a monotonic CAST(:value AS TEXT) transform, a January range mirrors as p >= '2026-01-01 00:00:00.000000', which sorts above the key '2026-01-01' and drops every January 1 row the filter keeps. Could the probe use the same rendering the engine gives the original bound (for example the date itself when the literal carries no time of day)?

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.

{ai generated comment}

Thanks, fixed in d913891. When the engine renders the bound and the column holds only days, _mirror_probe_value now returns dttm.date() at midnight, so the probe binds the same day the filter compares. Columns that store a time of day keep the datetime: TIMESTAMP, and Oracle DATE (via holds_days_only, which reads the dialect's own type). With your example run against a real SQLite file, a January range now mirrors as p >= '2026-01-01' AND p <= '2026-02-01' and keeps every January 1 row.

One note: at the head you reviewed, this case no longer dropped rows. The new two-shapes check saw the timestamp answer (…00:00:00.000000) disagree with the text one (…00:00:00) and declined the mirror, so results were correct but the pruning was lost. With the date probe the two forms agree, so the mirror is kept. Covered by test_a_midnight_bound_on_a_date_column_is_probed_as_the_day.

Comment thread superset/datasets/api.py
- escaping
- transform_escaping
- engine
- type

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.

_preview_probe() also returns HTTP 200 with reason: "shape" when the range and text probes emit different predicates (for example an Oracle TO_DATE(:value, 'YYYY-MM-DD HH24:MI:SS') transform on a temporal sample), but shape is not in this enum, the generated openapi.json entry, or the TypeScript union. A client generated from the spec with a strict enum would reject that response. Could shape be added to all three and the spec regenerated?

Comment thread UPDATING.md
enforced on every write rather than only inside `UpdateDatasetCommand`. A
transform arriving on any other column is dropped -- by the deprecated
`POST /datasource/save/`, and by `PUT /api/v1/dataset/<pk>` and dataset import
even when `PARTITION_FILTER_MAPPING` is off. An API client that was storing one there

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.

This says a transform sent on a non-mapped column is dropped and the field reads null afterwards, including with the flag off, and partition-filter-mapping.mdx repeats it. But drop_unmapped_value_transforms() deliberately keeps an unchanged echo of the stored value (stored_by_name), which is exactly what a GET-then-PUT, a legacy save, or an overwrite import sends. An operator who follows this note to clear a parked transform by re-saving the dataset will still find it there. Could both places state the unchanged-echo exception and say how to clear it (send null)?

@geido geido 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.

Thanks for the Oracle fixes, CAST(:value AS DATE) checks out here. I did a last pass on 81c5e54 against six engines: with the flag off I found no regressions against master, and with it on I found one new issue on ClickHouse (inline), while the TO_DATE thread still reproduces from the editor.

Comment thread superset/models/helpers.py Outdated
seen.add(key)
deduped.append((operator, value))

return build_mirrored_predicates(cast("SqlaTable", self), mapping, deduped)

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.

I think this can now fail every chart filtering the mapped column on ClickHouse. _holds_days_only (from 6f37942) calls .get on dialect.ischema_names, a list in clickhouse-connect 1.10/1.11, so toDate(:value) onto a Date key returns 500 with the flag on (200 off) and the preview shows "Fatal error". Could the lookup accept only a Mapping, and this call fail open, as the docs say?

ClickHouse, toDate(:value) onto a Date key: flag ON returns 500 ('list' object has no attribute 'get'), flag OFF returns 240/240 rows
mp4

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.

Thanks, my bug. Fixed in 83f0660f2a: the lookup only reads a Mapping and treats any failure as "may hold a time of day", and the chart path (and preview) now fail open on any error building the mirror.

hughhhh and others added 2 commits October 24, 2026 11:56
…ral shapes on charts

- _holds_days_only read dialect.ischema_names with .get, but
  clickhouse-connect 1.10/1.11 make it a list, so every chart filtering the
  mapped column returned 500 and the preview showed a fatal error. It now
  reads only a Mapping and treats any lookup failure as "may hold a time of
  day". The chart path's mirror build and the preview also fail open: an
  unexpected error costs the pruning, not the chart.
- The text-vs-timestamp check moves from the preview into
  build_mirrored_predicates, so charts run it too. evaluate_transform takes
  a text_answers sink and asks each date or timestamp as text in the same
  round trip (one probe per query still), retrying with the typed values
  alone if the text is refused. The text bypasses the mirror request gates,
  which declined it before the comparison on a TIMESTAMP column at a time
  of day, so the preview said valid for Oracle's TO_DATE(:value, fmt).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
continue
# `bool` is checked separately because it satisfies every numeric
# `isinstance` there is while rendering as `true`.
held = isinstance(value, allowed) and (

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.

A probe result of inf or nan passes this type check, so a transform such as CASE WHEN :value = 0 THEN CAST('Infinity' AS DOUBLE PRECISION) ELSE :value END on a PostgreSQL double partition column returns inf for n = 0. The mirrored predicate is then rendered as p = inf, which the database rejects (column "inf" does not exist), while preview still reports the mapping as valid, so the chart fails instead of just losing pruning. Should a non-finite float be treated as not held here so the mirror declines?

app.config["DEFAULT_FEATURE_FLAGS"]["PARTITION_FILTER_MAPPING"] = False

with app.app_context():
with patch(PROBE, side_effect=AssertionError("probe must not run")):

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.

Since the mirror builder now swallows any exception and returns [], the AssertionError raised by this booby-trapped probe is caught too, so the test passes whether or not the probe runs. If the chart path regressed and probed with the flag off, "dt_epoch" not in sql would still hold. Could this bind the patch (as probe) and assert probe.assert_not_called() after _query()? The same pattern is at the other side_effect=AssertionError(...) tests in this file.

@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.

The new typed-vs-text probe check leaves the stored mirror verdict wrong in both directions.

if isinstance(value, date) and not is_unmirrorable(value)
]
if indexes:
combined = evaluate_transform(

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.

On Oracle, CAST(:value AS DATE) and TRUNC(:value, 'HH') evaluate a typed bound but fail on its text form (ORA-01861, ORA-01722), so every time-range chart reruns this failing probe (failures are not cached) and stores evaluable=false, hiding the glyph while queries still prune.

if not _bounds_are_ordered(evaluated, spans):
return []

if _declined_for_reading_by_type(evaluated, text_answers, shape_errors):

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.

When this declines (Oracle TO_DATE(:value, fmt) puts the typed bound in year 0012), the stored verdict stays evaluable=true, so the time-range glyph keeps promising pruning that no time-range query gets.

@sha174n sha174n 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.

LGTM — the mirror is a strictly-narrowing redundant predicate; round-trip checks on the probe look thorough.

hughhhh and others added 2 commits October 26, 2026 12:10
- DrillDetailPane.test.tsx and tests/unit_tests/views/datasource/test_utils.py:
  both sides appended tests (this branch's lower-bound Samples paging,
  master's sunburst chart-type tests from #45571); kept both.
- superset/views/datasource/utils.py: #45571 retyped get_samples' payload
  from SamplesPayloadSchema to dict[str, Any] and dropped the import; the
  branch's _count_star_query_context now takes the same type, and the test
  that needed a type: ignore for the old one no longer does.
- Translations: took master's catalogs and re-ran
  scripts/translations/babel_update.sh on a tracked-files snapshot of the
  merged tree; against master only this branch's msgids and each file's
  POT-Creation-Date change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
parsed = make_url_safe(db_obj.sqlalchemy_uri)
if parsed.password and parsed.password != PASSWORD_MASK:
db_obj.set_sqlalchemy_uri(db_obj.sqlalchemy_uri)
imported.extend(db_obj.tables or [])

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.

db_obj.tables is every dataset attached to the database, not only the ones this bundle imported, so _repair_partition_mappings() also runs on unrelated datasets. Importing a legacy bundle that contains only dataset B therefore sends dataset A through clear_unmapped_partition_transforms, which drops A's parked transform and monotonicity declaration (for example one saved while the feature flag was off). Should this collect only the datasets the import actually wrote, rather than expanding the database relationship?

return True

rendered = _compile_literal(sa.literal(value), dialect)
if rendered == f"'{value}'" and "'" not in value and "\\" not in value:

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.

A probe result containing a NUL passes this short-circuit, since it has no quote or backslash and renders as '<value>' unchanged. On SQLite, mapping text column c to text partition column p with :value || char(0) returns 'a\x00' for c = 'a'; the guard accepts it, and the mirrored statement then fails with ProgrammingError: the query contains a null character, so the chart errors instead of just losing pruning. Should a value containing \x00 be treated as not round-tripping here?

@geido geido 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.

Thanks for 83f0660: the ClickHouse 500 and the HH24:MI:SS TO_DATE case both check out here on b32a525. One TO_DATE variant still empties time ranges, notes and a recording inline.

transform,
values + [_as_filter_text(values[index]) for index in indexes],
)
if combined is not None:

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.

I think a transform that refuses the text still slips through here. TO_DATE(:value, 'YYYY-MM-DD') onto a day key raises ORA-01830 on '2026-01-12 06:30:00', so this falls back to the typed answer (year 0012) unchecked: the preview says Valid and the range returns 0 rows (48 with the flag off), Last week too. Could a refused text form decline the temporal mirror instead?

Oracle, TO_DATE(:value, 'YYYY-MM-DD') onto a DATE day key on b32a525: preview Valid with year 0015, chart 0 rows with the flag on, 48 with it off
mp4 · v$sql and sqlplus replay

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.

{ai generated comment}

Thanks, agreed. Fixed in 09c728c5c4: a temporal value whose text form the transform refuses now gets no mirror (the typed answer can't be checked without it). Charts still do one probe, and the preview re-asks the typed value alone to say the text form was refused. Engines that write timestamps as plain text are unaffected.

hughhhh and others added 6 commits October 27, 2026 12:32
…refused

TO_DATE(:value, 'YYYY-MM-DD') onto an Oracle day key raises ORA-01830 on
'2026-01-12 06:30:00', so the combined probe failed and fell back to the
typed values alone -- whose answer, year 0012, then went unchecked: the
preview said valid and every time range (Last week too) returned 0 rows.
A transform that cannot read the instant as text cannot be checked, so it
now gets no mirror; the query path stops at its one round trip, and the
preview asks the typed values alone only to say why. Engines that write a
timestamp as plain text send the same SQL either way and are unaffected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Translations: tr/messages.po conflicted. Took master's catalogs and re-ran
scripts/translations/babel_update.sh on a tracked-files snapshot of the
merged tree, which also picks up the new partition-mapping message; no
master msgid is lost.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The filter compares a DATE column against the day itself ('2026-01-01' on
SQLite, DATE '2026-01-01' on Trino), but the probe was handed the midnight
datetime, which binds as '2026-01-01 00:00:00.000000'. On a text key
p = CAST(event_date AS TEXT) mirrored by CAST(:value AS TEXT), that asked
for p >= '2026-01-01 00:00:00.000000' and sorted above every January 1
key. The two-shapes check now declines that mirror, so results were
already correct, but the mapping lost its pruning.

_mirror_probe_value now returns the date when the engine renders the bound
and the column holds only days (holds_days_only, made public for this, so
an Oracle DATE, which stores the time of day, keeps its datetime).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nstant

Oracle refuses the text '2026-01-12 06:30:00' under its default
NLS_DATE_FORMAT for every transform, correct or not, so declining on the
refusal alone (09c728c) cost Oracle every time-range mirror:
TRUNC(:value) onto a day key previewed "not valid" and never pruned.

When the text is refused, the typed values are now asked alone (a second
round trip, only on that path) and kept where each answer is a date or
timestamp within a year and a day of the instant it was asked about, which
is the widest any time bucket can sit. TO_DATE(:value, 'YYYY-MM-DD')'s
year-0015 misreading and numeric answers still decline. Also rewords the
refusal message, which read "the timestamp's cannot be checked".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@geido geido 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.

Thanks for all the iterations here! I re-ran the full matrix on 738a278 across six engines and everything we flagged checks out, flag on and off. One thing before merging: the required unit tests fail because messages.pot is missing the new string, so it needs regenerating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Related to the REST API doc Namespace | Anything related to documentation i18n:brazilian i18n:chinese Translation related to Chinese language i18n:czech i18n:dutch i18n:french Translation related to French language i18n:italian Translation related to Italian language i18n:japanese Translation related to Japanese language i18n:korean Translation related to Korean language i18n:latvian i18n:persian i18n:portuguese i18n:russian Translation related to Russian language i18n:slovak i18n:spanish Translation related to Spanish language i18n:traditional-chinese i18n:ukrainian i18n Namespace | Anything related to localization packages risk:db-migration PRs that require a DB migration size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants