Skip to content

feat(datasets): partition filter mapping, stored in tables.extra - #44816

Closed
hughhhh wants to merge 2 commits into
masterfrom
hughhhh/tables-extra-no-migration
Closed

hughhhh wants to merge 2 commits into
masterfrom
hughhhh/tables-extra-no-migration

Conversation

@hughhhh

@hughhhh hughhhh commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

SUMMARY

Consolidates the four-PR partition-filter-mapping stack (#43757, #43758, #43759, #43760) into one PR, and replaces its four new database columns with a storage interface, so the feature ships with no Alembic migration. The migration was the only thing blocking deployment, and it gated the other three PRs behind it.

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.

A dataset owner names one partition column, one business column whose filters are mirrored onto it, a value transform (a SQL expression containing :value), and whether that transform preserves ordering. Superset then appends an equivalent predicate on the partition column to every query: chart authors change nothing and queries prune. Behind PARTITION_FILTER_MAPPING, off by default.

The storage interface

This follows the pattern already two screens away in superset/datasets/api.py, which exposes four properties over tables.extra (is_certified, certified_by, certification_details, warning_markdown) through show_columns, with a comment saying why. Here the same blob carries partition_filter_mapping.

Behind PartitionMappingStore — load/save, one adapter today (ExtraJsonPartitionMappingStore) and one that activates with the migration, selected by PARTITION_MAPPING_STORE. The model, the DAO, validation, the query rewriter and the preview endpoint are written against the port and never learn which store answered. A store-swap test runs the behavioural surface against a second, dict-backed implementation, so "we can move this" is a claim with evidence rather than an intention.

tables.extra turned out to be a reasonable home rather than only an expedient one:

  • it is already in SqlaTable.export_fields and already one of ExportDatasetsCommand's JSON_KEYS, so a mapping travels through import/export with no bundle-format change;
  • Continuum already versions the column, so dataset version history and restore work untouched — and no shadow-table migration is needed, which is the part the repo documents as unreliable to autogenerate;
  • the dataset editor round-trips dataset-level extra verbatim, and its one mutating path (setDatasetCertification) merges rather than rebuilds, so an unknown key survives a save.

It has to be the dataset-level blob, though, never table_columns.extra — buildExtraJsonObject rebuilds every column's and metric's extra from two keys on every editor save.

Two details worth a look

Transforms are keyed by column name, not flattened onto the mapping. Flattening is unsound: an owner who declares a transform on A (then main_dttm_col) and later re-points main_dttm_col to B would have B's values mirrored through A's expression. Keyed, B has no transform and the mapping goes inactive — which is exactly what four real columns would do. That parity is what makes the later migration a mechanical per-column copy.

The model's four attributes are read-only properties, and DatasetDAO extracts the mapping from a payload before anything is applied and writes it after everything is. The editor's PUT carries both the typed partition_column field and a verbatim copy of extra, and under this store those are the same bytes — so a setattr loop that happens to apply extra last silently discards the typed field, and which order that is depends on marshmallow's field ordering, not on anything visible at the call site. Read-only properties make that loss impossible rather than merely unlikely; set_partition_mapping is the one supported write. There is a test for each assignment raising, so nobody reintroduces setters later.

Two bugs in the original stack, fixed here

  • _transform_is_usable omitted the non-deterministic denylist, so a transform calling now() that reached storage without passing UpdateDatasetCommand — via create, via import, or via the free-text Extra box, which every dataset owner can reach — was mirrored at query time and its result cached for a day. Replaced by is_transform_active, which is validate_transform with the messages discarded and therefore cannot drift from the save path. Net −13 lines.
  • columns.partition_value_transform was missing from the dataset GET payload while DatasourceModal PUT it back for every column, so every dataset-editor save cleared the transform.

Also new here: partition_column is a physical column name, so it joins DASHBOARD_DATASET_INACCESSIBLE_FIELDS alongside columns and sql; DatasetPutSchema.extra gains a structural validator for the mapping key, because the Extra box is a second door into the same storage and a mistyped value there would otherwise be silently ignored; and SqlaTable.update_from_object preserves the mapping when a legacy payload omits extra.

The follow-up migration

Not just ADD COLUMN. In one revision it must: add the four columns to tables/table_columns and to the *_version shadow tables; backfill in a Python batch loop over rows whose extra holds the key (not raw JSON SQL — migrations run on sqlite/MySQL/Postgres), leaving a blob it cannot parse in place rather than dropping an owner's configuration; strip the key; delete the facade properties and declare the real columns in the same commit (a property and a Column of the same name cannot coexist); fill in ColumnPartitionMappingStore; add the four names to export_fields; flip PARTITION_MAPPING_STORE. ColumnPartitionMappingStore's docstring carries that list, and its NotImplementedError names the migration.

It is deliberately not implemented now: it would read table.partition_column, which today is the facade property, which calls the store — unbounded recursion. Written against private attribute names instead it could only ever be exercised against a hand-built stand-in, which proves nothing about the parts that are actually hard.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — no UI. As in the original stack, there are no editor form fields for this; a mapping is configured through the REST API or the Extra box, and the preview endpoint ships available but uncalled. The docs say so explicitly.

TESTING INSTRUCTIONS

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

partition_mapping_storage_test.py is the file to read first: round-tripping, defensive parsing of a blob an owner typed by hand, the memo, read-only enforcement, the factory, and the store-swap parity test.

Two tests in tests/unit_tests/dao/dataset_test.py are the ones this design exists for:
test_a_typed_field_beats_a_stale_extra_in_the_same_payload and
test_a_mapping_written_through_extra_alone_lands. Both fail if the funnel is ever "simplified" back into property setters.

Manually, with PARTITION_FILTER_MAPPING: True:

  1. PUT /api/v1/dataset/<id> with partition_column, and partition_value_transform + partition_transform_is_monotonic on a column.
  2. SELECT extra FROM tables WHERE id = <id> — the blob holds partition_filter_mapping and every pre-existing key is intact.
  3. Open the dataset editor, change a column description, save. Re-check step 2: the mapping is still there. This is the ordering hazard; if the funnel were wrong, this is where the mapping would disappear.
  4. Add a certification and save. Both the certification and the mapping are present.
  5. Build a chart filtered on the mapped column; View query shows the mirrored predicate on the partition column.
  6. Export the dataset to a zip, delete it, re-import — the mapping comes back.
  7. Type {"partition_filter_mapping": 42} into the Extra box and save — rejected with a readable message rather than silently ignored.
  8. Set PARTITION_MAPPING_STORE = "columns" and restart — a clear NotImplementedError naming the migration, not a mystery 500.

Verified: 2949 backend unit tests green across the touched surface, plus a full tests/unit_tests sweep at 8479 passed / 4 failed, those 4 being a pre-existing mcp_service trio-parameterised failure confirmed identical on pristine master. Frontend partitionMapping.test.ts green. ruff check and ruff format --check clean. docs/static/resources/openapi.json regenerated with superset update-api-docs (+165 lines, purely additive).

git diff origin/master -- superset/migrations/ is empty, which is the point.

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
  • Introduces new feature or API
  • Removes existing feature or API

Notes for review

  • Message catalogs are regenerated, so the diff carries the usual catalog churn. Besides the feature's own strings it also folds in master's own lag: "Excel export is not configured on this server." is no longer wrapped in _() anywhere in source, so pybabel update --ignore-obsolete prunes it from 31 catalogs, and two .pot entries are rewrapped. scripts/translations/check_pot_drift.py confirms the template matches a fresh extraction.
  • superset/connectors/sqla/partition_mapping.py was left as one module with the new storage layer as a sibling, partition_mapping_storage.py, rather than split into a package. The split is defensible on size alone, but it would have turned a reviewable diff against the original stack into a moved-everything diff, and it carries a specific trap: partition_mirroring_test.py patches ...partition_mapping.evaluate_transform, which a package split silently turns into a no-op that fails as a confusing assertion error.

🤖 Generated with Claude Code

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.

A dataset owner names one partition column, one business column whose filters
are mirrored onto it, a value transform (a SQL expression containing `:value`),
and whether that transform preserves ordering. Superset then appends an
equivalent predicate on the partition column to every query: chart authors
change nothing and queries prune. Behind `PARTITION_FILTER_MAPPING`, off by
default.

This consolidates what was a four-PR stack (#43757, #43758, #43759, #43760) and
replaces its four new database columns with a storage interface, so the feature
ships with no Alembic migration and the columns land later as an additive
follow-up.

Storage
-------
The four values live in `tables.extra` under `partition_filter_mapping`, behind
`PartitionMappingStore`: `load`/`save`, one adapter today
(`ExtraJsonPartitionMappingStore`) and one that activates with the migration,
selected by `PARTITION_MAPPING_STORE`. The model, the DAO, validation, the query
rewriter and the preview endpoint are written against the port and never learn
which store answered.

`tables.extra` is a reasonable home rather than only an expedient one: it is
already in `SqlaTable.export_fields` and already one of `ExportDatasetsCommand`'s
`JSON_KEYS`, so a mapping travels through import/export with no bundle-format
change; Continuum already versions the column, so dataset version history and
restore work untouched; and `certification` and `warning_markdown` already prove
the pattern of surfacing typed settings out of that blob through model
properties. It has to be the dataset-level blob, though, never
`table_columns.extra` -- the editor's `buildExtraJsonObject` rebuilds every
column's `extra` from two keys on each save.

Two details worth a look:

- **Transforms are keyed by column name, not flattened onto the mapping.**
  Flattening is unsound: an owner who declares a transform on `A` and later
  re-points `main_dttm_col` to `B` would have `B`'s values mirrored through
  `A`'s expression. Keyed, `B` has no transform and the mapping goes inactive --
  which is what four real columns would do.

- **The model's four attributes are read-only properties, and `DatasetDAO`
  extracts the mapping from a payload before anything is applied and writes it
  after everything is.** The editor's PUT carries both the typed
  `partition_column` field and a verbatim copy of `extra`, and under this store
  those are the same bytes -- so a `setattr` loop that happens to apply `extra`
  last silently discards the typed field, and which order that is depends on
  marshmallow's field ordering. Read-only properties make that loss impossible
  rather than merely unlikely; `set_partition_mapping` is the one supported
  write.

Two bugs in the original stack, fixed here
------------------------------------------
- `_transform_is_usable` omitted the non-deterministic denylist, so a transform
  calling `now()` that reached storage without passing `UpdateDatasetCommand` --
  via create, via import, or via the free-text Extra box, which every dataset
  owner can reach -- was mirrored at query time and its result cached. Replaced
  by `is_transform_active`, which is `validate_transform` with the messages
  discarded and so cannot drift from the save path.
- `columns.partition_value_transform` was missing from the dataset GET payload
  while `DatasourceModal` PUT it back for every column, so every dataset-editor
  save cleared the transform.

Also new: `partition_column` is a physical column name, so it joins
`DASHBOARD_DATASET_INACCESSIBLE_FIELDS`; `DatasetPutSchema.extra` gains a
structural validator for the mapping key, because the Extra box is a second door
into the same storage and a mistyped value there would otherwise be silently
ignored; and `SqlaTable.update_from_object` preserves the mapping when a legacy
payload omits `extra`.

No authoring UI is added, as in the original stack: a mapping is configured
through the REST API or the Extra box, and the preview endpoint ships available
but uncalled.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@bito-code-review

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

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Large PR

Bito didn't auto-review this change because the pull request exceeded the line limit. 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.

@github-actions github-actions Bot added api Related to the REST API doc Namespace | Anything related to documentation packages labels Sep 30, 2026
@netlify

netlify Bot commented Sep 30, 2026

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

Comment on lines +372 to +377
"partition_column": ColumnMetadata(
name="partition_column",
description="Physical column the engine partitions on",
type="str",
is_default=False,
),

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: partition_column is advertised as selectable, but DatasetInfo has no matching field, so Pydantic drops it from every MCP dataset response.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Api mismatch

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/mcp_service/common/schema_discovery.py
**Line:** 372:377
**Comment:**
	*Api Mismatch: `partition_column` is advertised as selectable, but `DatasetInfo` has no matching field, so Pydantic drops it from every MCP dataset response.

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
Member

Choose a reason for hiding this comment

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

Agreed—the new selectable partition fields are absent from DatasetInfo, so get_dataset_info drops them when validating its output. Can the response schema carry both fields as well?

@bito-code-review

Copy link
Copy Markdown
Contributor

The issue is valid. The partition_column field is missing from the DatasetInfo Pydantic schema, causing it to be dropped during serialization. To resolve this, you need to add partition_column to the DatasetInfo schema definition in superset/mcp_service/common/schema_discovery.py (or the relevant schema file).

Here is the suggested fix:

# Add this to the DatasetInfo properties
"partition_column": {
    "description": "The physical column the engine partitions on",
    "type": "string",
    "nullable": true
},

I have checked the PR and there are no other pending review comments. Would you like me to proceed with any other tasks?

superset/mcp_service/common/schema_discovery.py

"partition_column": {
    "description": "The physical column the engine partitions on",
    "type": "string",
    "nullable": true
},

Comment thread superset/datasets/api.py
"get_or_create_dataset",
"warm_up_cache",
"get_drill_info",
"partition_mapping_preview",

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 new route is not mapped to the dataset write permission, so @protect() falls back to an undefined method permission and normal editors cannot use the preview.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Api mismatch

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/datasets/api.py
**Line:** 263:263
**Comment:**
	*Api Mismatch: The new route is not mapped to the dataset `write` permission, so `@protect()` falls back to an undefined method permission and normal editors cannot use the preview.

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
👍 | 👎

Comment on lines +195 to +204
partition_value_transform = fields.String(
allow_none=True,
metadata={
"description": (
"SQL expression containing a :value placeholder. Filters on "
"this column are mirrored onto the dataset's partition column "
"with the value passed through this 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.

Suggestion: partition_value_transform has no length validator, so oversized values pass validation, are stored, then are silently ignored by parse_mapping after consuming parser and validation resources.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Possible bug

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/datasets/schemas.py
**Line:** 195:204
**Comment:**
	*Possible Bug: `partition_value_transform` has no length validator, so oversized values pass validation, are stored, then are silently ignored by `parse_mapping` after consuming parser and validation resources.

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
Member

Choose a reason for hiding this comment

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

Agreed—a typed transform longer than 4096 characters can be accepted and stored, then _as_transform reads it back as unset and pruning silently stops. Can the typed field enforce the same length bound as the Extra schema and storage reader?

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.

Yes. The typed field should use the same MAX_TRANSFORM_LENGTH bound as extra validation and parse_mapping; otherwise an overlong transform is accepted by the API, persisted, then treated as inactive on read.

Update the schema field to:

partition_value_transform = fields.String(
    allow_none=True,
    validate=Length(1, MAX_TRANSFORM_LENGTH),
    metadata={
        "description": (
            "SQL expression containing a :value placeholder. Filters on "
            "this column are mirrored onto the dataset's partition column "
            "with the value passed through this transform."
        )
    },
)

Also add a schema test asserting that a value longer than MAX_TRANSFORM_LENGTH is rejected. This keeps the typed API, extra validation, and storage reader consistent, while preventing oversized input from reaching parsing or persistence.

Comment on lines +2027 to +2029
super().update_from_object(obj)
if "extra" not in obj and not mapping.is_empty:
partition_mapping_store().save(self, mapping)

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: When the editor payload omits extra, super() first clears it, then saving only the mapping recreates the blob without certification, timezone, or other existing extra settings.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Logic error

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/models.py
**Line:** 2027:2029
**Comment:**
	*Logic Error: When the editor payload omits `extra`, `super()` first clears it, then saving only the mapping recreates the blob without certification, timezone, or other existing extra settings.

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
👍 | 👎

Comment on lines +518 to +535
payload = json.dumps(
[
database.id,
database.backend,
# The probe asks this connection to evaluate the transform, so the
# answer belongs to it. `id` outlives an edit to the URI or to
# `extra` (a session timezone, say), which would otherwise serve
# values computed against the old environment until the entry
# expires. `changed_on` covers the edits that do not show up here,
# such as a rotated password, without putting a secret in the key.
database.sqlalchemy_uri,
database.extra,
str(database.changed_on),
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 the authenticated user, so OAuth2 users can reuse transform results computed under another user's database permissions or session.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Security

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:** 518:535
**Comment:**
	*Security: The probe cache key omits the authenticated user, so OAuth2 users can reuse transform results computed under another user's database permissions or session.

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
👍 | 👎

Comment on lines +234 to +246
def save(self, table: SqlaTable, mapping: StoredPartitionMapping) -> None:
raw = getattr(table, "extra", None)
updated = extra_with_partition_mapping(raw, mapping)
if updated is raw:
# `extra_with_partition_mapping` hands back the identical object when
# the blob already says this. Writing anyway would dirty the column
# and mint a Continuum version row for an edit that changed nothing.
return
# A *new string*, never a mutation of the parsed dict. `decode_extra`
# parses fresh and throws its dict away, so mutating one would change
# nothing on the model and SQLAlchemy would never see the attribute as
# dirty. Assignment is also what invalidates `load`'s memo.
table.extra = updated

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: Concurrent saves read the same extra, then each writes a replacement, so one update can silently erase another update's unrelated dataset settings.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Race condition

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_storage.py
**Line:** 234:246
**Comment:**
	*Race Condition: Concurrent saves read the same `extra`, then each writes a replacement, so one update can silently erase another update's unrelated dataset settings.

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
👍 | 👎

Comment thread superset/daos/dataset.py
Comment on lines +489 to +492
updated = super().update(item, attributes)

if mapping_patch is not None or surviving_column_names is not None:
cls.save_partition_mapping(updated, mapping_patch, surviving_column_names)

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: save_partition_mapping performs a separate read and write after the dataset update, so concurrent edits to other extra keys can be overwritten.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Race condition

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/daos/dataset.py
**Line:** 489:492
**Comment:**
	*Race Condition: `save_partition_mapping` performs a separate read and write after the dataset update, so concurrent edits to other `extra` keys can be overwritten.

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
👍 | 👎

Comment on lines +186 to +187
partition_column: datasource.partition_column ?? null,
partition_mapped_column: datasource.partition_mapped_column ?? null,

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 modal always sends stale typed mapping fields, so editing the mapping only in Extra is overwritten by the previously loaded values.

Assessment: 🟠 Major · 🔁 Occurrence: Sometimes · 🏷️ Api mismatch

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-frontend/src/components/Datasource/DatasourceModal/index.tsx
**Line:** 186:187
**Comment:**
	*Api Mismatch: The modal always sends stale typed mapping fields, so editing the mapping only in Extra is overwritten by the previously loaded values.

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
Member

Choose a reason for hiding this comment

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

Agreed—on a dataset with no existing mapping, adding one in the documented Extra box still sends null table fields and null column transforms, and the DAO patch clears the newly entered mapping on a successful save. Can this editor avoid resending stale typed mapping values when Extra is the source of the edit?

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.

Yes, this is a valid issue. DatasourceModal currently always includes:

partition_column: datasource.partition_column ?? null,
partition_mapped_column: datasource.partition_mapped_column ?? null,

When extra was edited directly, these values may be stale (or null). DatasetDAO treats present typed fields as a patch, so they overwrite the mapping parsed from extra.

The editor should treat extra as authoritative when it is the source of the edit. Track the initial extra value and omit the typed mapping fields—and the per-column transform fields—when extra has changed independently. This lets the DAO persist the mapping from extra without applying a stale typed patch.

Alternatively, the backend can enforce the same rule: when extra is present in the request, do not apply typed mapping fields unless they were explicitly changed. The latter is safer for non-frontend clients, while the frontend change prevents the problematic payload from being generated. This should be fixed before merging; otherwise editing the Extra box can silently discard the newly entered mapping.

Comment on lines +1341 to +1353
const clearedMapping = clearDanglingPartitionMapping(
datasource,
columnChanges.finalColumns,
);
if (clearedMapping) {
onDatasourcePropChange(
'partition_column',
clearedMapping.partition_column,
);
onDatasourcePropChange(
'partition_mapped_column',
clearedMapping.partition_mapped_column,
);

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: A completed metadata request uses its captured datasource and can clear a newer mapping changed while that request was still pending.

Assessment: 🟠 Major · 🔁 Occurrence: Rarely · 🏷️ Stale reference

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-frontend/src/components/Datasource/components/DatasourceEditor/DatasourceEditor.tsx
**Line:** 1341:1353
**Comment:**
	*Stale Reference: A completed metadata request uses its captured datasource and can clear a newer mapping changed while that request was still pending.

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
👍 | 👎

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.00529% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.61%. Comparing base (1dbb7aa) to head (1414290).
⚠️ Report is 31 commits behind head on master.

Files with missing lines Patch % Lines
superset/connectors/sqla/partition_mapping.py 91.72% 15 Missing and 7 partials ⚠️
...erset/connectors/sqla/partition_mapping_storage.py 92.59% 6 Missing and 8 partials ⚠️
superset/models/helpers.py 86.66% 2 Missing and 6 partials ⚠️
superset/datasets/api.py 85.00% 5 Missing and 1 partial ⚠️
superset/commands/dataset/update.py 83.87% 4 Missing and 1 partial ⚠️
superset/connectors/sqla/models.py 90.47% 3 Missing and 1 partial ⚠️
superset/datasets/schemas.py 91.66% 2 Missing and 2 partials ⚠️
...e/components/DatasourceEditor/DatasourceEditor.tsx 40.00% 3 Missing ⚠️
superset/daos/dataset.py 93.75% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #44816      +/-   ##
==========================================
+ Coverage   81.56%   81.61%   +0.05%     
==========================================
  Files        2977     2979       +2     
  Lines      180665   181524     +859     
  Branches    41779    41958     +179     
==========================================
+ Hits       147352   148155     +803     
- Misses      30591    30619      +28     
- Partials     2722     2750      +28     
Flag Coverage Δ
hive 36.60% <27.81%> (-0.09%) ⬇️
javascript 77.03% <84.21%> (+<0.01%) ⬆️
mysql 55.80% <42.06%> (-0.15%) ⬇️
postgres 55.81% <42.06%> (-0.15%) ⬇️
presto 38.51% <29.17%> (-0.10%) ⬇️
python 85.77% <91.18%> (+0.06%) ⬆️
sqlite 55.54% <42.06%> (-0.15%) ⬇️
unit 78.64% <90.09%> (+0.15%) ⬆️

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.

Three CI failures, three unrelated causes:

- **mypy.** `DatasetColumnData` never gained `partition_value_transform` /
  `partition_transform_is_monotonic`, so any test reading them off a
  `TableColumn.data` payload was a `typeddict-item` error. The original stack
  added the dataset-level keys to `ExplorableData` and missed the column-level
  ones.

- **babel-extract / check_pot_drift.** I was wrong that nothing enforces
  extraction: `scripts/translations/check_pot_drift.py` does, from both a
  workflow and a unit test. Regenerated with
  `scripts/translations/babel_update.sh`. Besides the feature's own strings the
  catalogs also pick up master's own lag, which is why the diff is larger than
  the new msgids alone: `"Excel export is not configured on this server."` is no
  longer wrapped in `_()` anywhere in source, so `pybabel update
  --ignore-obsolete` prunes it from 31 catalogs, and two `.pot` entries are
  rewrapped. Both are correct output rather than churn to undo.

- **The validator's own messages were unextractable.** `_reject` took a format
  string and called `_()` on it, so `pybabel extract` -- which only sees `_()`
  around a literal -- would have left all eight of them out of the catalogs,
  untranslatable in every language, with nothing to catch it. It now takes an
  already-translated message and every literal sits under its own `_()`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@github-actions github-actions Bot added i18n Namespace | Anything related to localization i18n:spanish Translation related to Spanish language i18n:italian Translation related to Italian language i18n:french Translation related to French language i18n:chinese Translation related to Chinese language i18n:japanese Translation related to Japanese language i18n:russian Translation related to Russian language i18n:korean Translation related to Korean language i18n:dutch i18n:slovak labels Sep 30, 2026
distinct: list[Any],
) -> list[Any] | None:
try:
sql = build_probe_sql(transform, distinct, _dialect_for(database))

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 probe bypasses the stored-expression subquery policy and RLS injection: an Alpha dataset owner without sql_lab can submit a scalar SELECT through preview and receive its result in emitted_predicate, and imported mappings reach the same sink. Can the probe enforce the same subquery/access/RLS checks as stored expressions before executing SQL?

# bucket width has to be added there too. The two commute for the
# hour-offset branch but not for the `ZoneInfo` one, where widening
# across a DST boundary first lands an hour out.
upper_operator = utils.FilterOperator.LESS_THAN

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 monotonic transform can collapse distinct timestamps: with p = date_format(ts, 'yyyy-MM-dd'), a 10:00 row satisfies ts < '2026-02-01 12:00' but fails the added p < '2026-02-01'. Can strict bounds become inclusive on the partition column, both here and for structured </> filters?

"Partition transform probe returned no rows; skipping mirroring"
)
return None
row = frame.iloc[0]

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.

lower(:value), 'x' passes the current parse check, but probing IN ('US', 'CA') returns ('us', 'x', 'ca', 'x'); taking the first two columns produces a partition filter that drops the matching CA rows. Can validation require exactly one expression and the probe reject any result whose column count differs from the number of inputs?

"""
selections = []
for index, value in enumerate(values):
clause = sa.text(transform).bindparams(sa.bindparam("value", value=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.

For timestamp filters supplied as epoch milliseconds, filter_values_handler returns a SQLAlchemy literal_column such as Hive's CAST(... AS TIMESTAMP), which cannot be rendered as this bound literal. The probe catches the resulting CompileError and silently skips pruning for equality, IN, and comparison filters; can these values be normalized to actual temporal values before binding?

@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 — model, migration, query rewrite, preview, editor UI and the Explore indicator — in a single PR against master.

This PR's contribution was the storage question: it replaced the four new columns with a PartitionMappingStore port over tables.extra so the feature could ship with no Alembic migration. #43870 keeps the migration, so that trade is not being taken. The argument for real columns is in its summary; the argument against the blob is the one this PR's own description makes about extra being a user-editable free-text box that buildExtraJsonObject rebuilds on every save.

Two things from here were worth keeping and are in #43870 independently of the storage choice:

  • _transform_is_usable omitted the non-deterministic denylist, so a transform calling now() that reached storage without passing UpdateDatasetCommand was mirrored at query time and its result cached. Fixed in 7951536198 by deleting the function in favour of is_transform_active, the same shape this PR proposed.
  • columns.partition_value_transform was missing from the dataset GET payload while DatasourceModal PUT it back for every column, so every editor save cleared the transform. Fixed on the stack before this pass.

If the migration turns out to be the blocker for deployment, this is the conversation to reopen — the branch is still there. @sadpandajoe your four comments here are unaddressed and still stand against this approach; they are not carried into #43870 because they are about the tables.extra store, which it does not have.

@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

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 requires:rebase Requires rebasing on top of current master size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants