Repository navigation
Conversation
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 Automatic Review Skipped - Large PR |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
| "partition_column": ColumnMetadata( | ||
| name="partition_column", | ||
| description="Physical column the engine partitions on", | ||
| type="str", | ||
| is_default=False, | ||
| ), |
There was a problem hiding this comment.
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
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 fixThere was a problem hiding this comment.
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?
|
The issue is valid. The 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 |
| "get_or_create_dataset", | ||
| "warm_up_cache", | ||
| "get_drill_info", | ||
| "partition_mapping_preview", |
There was a problem hiding this comment.
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
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| 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." | ||
| ) | ||
| }, | ||
| ) |
There was a problem hiding this comment.
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
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 fixThere was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| super().update_from_object(obj) | ||
| if "extra" not in obj and not mapping.is_empty: | ||
| partition_mapping_store().save(self, mapping) |
There was a problem hiding this comment.
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
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| 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], | ||
| ], |
There was a problem hiding this comment.
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
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| 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 |
There was a problem hiding this comment.
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
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| 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) |
There was a problem hiding this comment.
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
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| partition_column: datasource.partition_column ?? null, | ||
| partition_mapped_column: datasource.partition_mapped_column ?? null, |
There was a problem hiding this comment.
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
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 fixThere was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
| const clearedMapping = clearDanglingPartitionMapping( | ||
| datasource, | ||
| columnChanges.finalColumns, | ||
| ); | ||
| if (clearedMapping) { | ||
| onDatasourcePropChange( | ||
| 'partition_column', | ||
| clearedMapping.partition_column, | ||
| ); | ||
| onDatasourcePropChange( | ||
| 'partition_mapped_column', | ||
| clearedMapping.partition_mapped_column, | ||
| ); |
There was a problem hiding this comment.
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
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 Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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]>
| distinct: list[Any], | ||
| ) -> list[Any] | None: | ||
| try: | ||
| sql = build_probe_sql(transform, distinct, _dialect_for(database)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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?
|
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 This PR's contribution was the storage question: it replaced the four new columns with a Two things from here were worth keeping and are in #43870 independently of the storage choice:
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 |
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. BehindPARTITION_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 overtables.extra(is_certified,certified_by,certification_details,warning_markdown) throughshow_columns, with a comment saying why. Here the same blob carriespartition_filter_mapping.Behind
PartitionMappingStore—load/save, one adapter today (ExtraJsonPartitionMappingStore) and one that activates with the migration, selected byPARTITION_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.extraturned out to be a reasonable home rather than only an expedient one:SqlaTable.export_fieldsand already one ofExportDatasetsCommand'sJSON_KEYS, so a mapping travels through import/export with no bundle-format change;extraverbatim, 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—buildExtraJsonObjectrebuilds every column's and metric'sextrafrom 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(thenmain_dttm_col) and later re-pointsmain_dttm_coltoBwould haveB's values mirrored throughA's expression. Keyed,Bhas 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
DatasetDAOextracts the mapping from a payload before anything is applied and writes it after everything is. The editor's PUT carries both the typedpartition_columnfield and a verbatim copy ofextra, and under this store those are the same bytes — so asetattrloop that happens to applyextralast 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_mappingis 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_usableomitted the non-deterministic denylist, so a transform callingnow()that reached storage without passingUpdateDatasetCommand— 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 byis_transform_active, which isvalidate_transformwith the messages discarded and therefore cannot drift from the save path. Net −13 lines.columns.partition_value_transformwas missing from the dataset GET payload whileDatasourceModalPUT it back for every column, so every dataset-editor save cleared the transform.Also new here:
partition_columnis a physical column name, so it joinsDASHBOARD_DATASET_INACCESSIBLE_FIELDSalongsidecolumnsandsql;DatasetPutSchema.extragains 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; andSqlaTable.update_from_objectpreserves the mapping when a legacy payload omitsextra.The follow-up migration
Not just
ADD COLUMN. In one revision it must: add the four columns totables/table_columnsand to the*_versionshadow tables; backfill in a Python batch loop over rows whoseextraholds 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 aColumnof the same name cannot coexist); fill inColumnPartitionMappingStore; add the four names toexport_fields; flipPARTITION_MAPPING_STORE.ColumnPartitionMappingStore's docstring carries that list, and itsNotImplementedErrornames 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.pypartition_mapping_storage_test.pyis 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.pyare the ones this design exists for:test_a_typed_field_beats_a_stale_extra_in_the_same_payloadandtest_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:PUT /api/v1/dataset/<id>withpartition_column, andpartition_value_transform+partition_transform_is_monotonicon a column.SELECT extra FROM tables WHERE id = <id>— the blob holdspartition_filter_mappingand every pre-existing key is intact.{"partition_filter_mapping": 42}into the Extra box and save — rejected with a readable message rather than silently ignored.PARTITION_MAPPING_STORE = "columns"and restart — a clearNotImplementedErrornaming the migration, not a mystery 500.Verified: 2949 backend unit tests green across the touched surface, plus a full
tests/unit_testssweep at 8479 passed / 4 failed, those 4 being a pre-existingmcp_servicetrio-parameterised failure confirmed identical on pristinemaster. FrontendpartitionMapping.test.tsgreen.ruff checkandruff format --checkclean.docs/static/resources/openapi.jsonregenerated withsuperset update-api-docs(+165 lines, purely additive).git diff origin/master -- superset/migrations/is empty, which is the point.ADDITIONAL INFORMATION
PARTITION_FILTER_MAPPING(off by default)Notes for review
"Excel export is not configured on this server."is no longer wrapped in_()anywhere in source, sopybabel update --ignore-obsoleteprunes it from 31 catalogs, and two.potentries are rewrapped.scripts/translations/check_pot_drift.pyconfirms the template matches a fresh extraction.superset/connectors/sqla/partition_mapping.pywas 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.pypatches...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