Repository navigation
Conversation
|
Bito Automatic Review Skipped - Branch Excluded |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## hughhhh/pfm-2-query-rewrite #43759 +/- ##
============================================================
Coverage 81.74% 81.74%
============================================================
Files 2979 2979
Lines 182029 182109 +80
Branches 42066 42084 +18
============================================================
+ Hits 148794 148860 +66
- Misses 30500 30512 +12
- Partials 2735 2737 +2
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:
|
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
3d7615a to
3c96ebe
Compare
c7a6548 to
a45d99f
Compare
3c96ebe to
218eec5
Compare
a45d99f to
0b835a9
Compare
218eec5 to
0927c4a
Compare
0b835a9 to
a2d7cb3
Compare
0927c4a to
7ad9986
Compare
a2d7cb3 to
44d5539
Compare
7ad9986 to
d33754b
Compare
44d5539 to
1da5aa6
Compare
d33754b to
9c5b4a6
Compare
1da5aa6 to
dd8b41e
Compare
9c5b4a6 to
e14aad3
Compare
dd8b41e to
9062521
Compare
e14aad3 to
c90781e
Compare
9062521 to
935ac3b
Compare
c90781e to
21693ee
Compare
| ever have been right for strings. | ||
| """ | ||
| return str( | ||
| sa.literal(value).compile( |
There was a problem hiding this comment.
A successful integer probe returns a NumPy scalar from the pandas row, but sa.literal() cannot infer its SQL type, so the canonical epoch transform raises CompileError here and preview returns 500. Could the probed scalar be normalized or rendered with an explicit type, with coverage through a real DataFrame result rather than a mocked Python int?
| is_active: column.is_active, | ||
| is_dttm: column.is_dttm, | ||
| python_date_format: column.python_date_format || null, | ||
| partition_value_transform: column.partition_value_transform || null, |
There was a problem hiding this comment.
The Dataset List editor loads /api/v1/dataset/{id}, whose column response omits both transform fields, so an unrelated save now sends null/false and overwrites an existing mapping, silently disabling pruning. Could those fields be included in the GET response and the GET→edit→PUT round trip be covered?
| ): | ||
| return {"valid": False, "error": str(issue.message)} | ||
|
|
||
| evaluated = evaluate_transform( |
There was a problem hiding this comment.
A dataset editor without SQL Lab can submit a scalar subquery as the unsaved transform and receive its warehouse result in emitted_predicate; this path never applies the subquery/RLS checks used for stored expressions. Could the shared SQL policy and row-level-security validation run before the probe, so preview cannot read rows the editor is not authorized to retrieve?
| if backend.add(key, 1, timeout=PREVIEW_RATE_LIMIT_WINDOW): | ||
| # First request of a fresh window, and the only one that dates it. | ||
| return True | ||
| used = backend.inc(key) |
There was a problem hiding this comment.
If the Redis key expires after add() returns false but before inc(), INCR recreates it without a TTL. That counter then never resets, so this user eventually gets permanent 429s for the dataset; could creation/increment/expiry be atomic or missing expiry be repaired?
…mbing
Third of four. Adds the server-side half of the dataset editor experience: an
endpoint that shows an owner the predicate their transform would emit, plus the
frontend types and save-payload wiring the editor UI will need.
The preview endpoint fires a real warehouse query from a text input, so the
order of its guards is the point. Parse and denylist checks run before anything
reaches the engine, which means a half-typed transform -- by definition
unparseable, and most of what a text input produces -- costs zero queries. Behind
that sits the same evaluator and cache the query path uses, so preview and
runtime cannot drift and a previewed transform warms the chart path for free.
A per-user, per-dataset rate limit backs it up: debouncing on the client is a
courtesy, not a guard, and a held keydown or a few owners with the editor open
is sustained load on a production cluster.
On the frontend, this is the plumbing rather than the UI:
- `partition_column` / `partition_mapped_column` in the dataset save payload
and `partition_value_transform` / `partition_transform_is_monotonic` in the
per-column whitelist. Anything outside that whitelist is silently dropped
on save.
- `clearDanglingPartitionMapping`, applied after a metadata sync. The backend
clears a dangling mapping too on the authoritative `override_columns` path;
this keeps the editor's own state honest in between, so an owner is never
looking at a mapping that points at a column the table no longer has.
- A test pinning down that a sync *preserves* a hand-written transform, which
is the failure the whitelist and the merge logic could each cause quietly.
The visual editor controls (the partition column select, the PARTITION tag, the
row-expand section) are not in this PR.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ndow Three review findings on the preview endpoint, all in the same few lines. The throttle counted with a read-then-write pair, so concurrent previews could each read the same sub-limit value and all reach the warehouse -- the burst the guard exists to stop was the one case it let through. It also re-stamped the key's expiry on every increment, making it a sliding window despite the docstring promising a fixed one: sustained typing could keep the budget spent indefinitely instead of recovering a minute after the burst began. `add` then `inc` fixes both. On Redis those compile to SETNX and INCR, so the count is atomic and INCR leaves the TTL alone -- only `add` ever dates the key. Both calls go to the cachelib backend rather than the Flask-Caching wrapper, which proxies `add` but not `inc`; routing `inc` through the wrapper raises AttributeError, which the fall-open handler would have swallowed into no throttling at all. A backend that cannot count still falls open, because unenforceable is not the same as spent. The preview request schema had no length bounds, so an owner could hand the parser and the warehouse arbitrarily large input. `value_transform` is capped at 1024 -- the stored column is Text, so this bounds the request rather than the feature -- and the two column-ish fields at 250, matching their storage. `_render_literal` formatted probed values by hand: quote-doubling for strings and `str()` for everything else, so a NULL rendered as the Python repr `None` and a date came out unquoted. Neither is SQL. It now compiles through the dialect, the same mechanism `build_probe_sql` already uses. The partition column is quoted with `quote_identifier` while it is being interpolated, so a column whose name needs quoting no longer renders as invalid SQL either. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The preview endpoint and the editor plumbing introduce five user-facing strings. On the merge-based stack they reached the catalogs inside the `origin/master` and pfm-2 merge commits, which a linear history has no room for, so they travel in their own commit instead -- otherwise this branch's own babel-extract job runs against a `.pot` that lacks them. Additions only: the five msgids propagated into all 30 catalogs, no POT-Creation-Date churn. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Four review findings on the preview PR. **Preview skipped the stored-expression policy.** `build_probe_sql` binds `:value` and splices the rest of the transform in as SQL text, and preview evaluates a candidate transform that has not been saved -- so the subquery, RLS and function-denylist gate that `UpdateDatasetCommand` applies to the *stored* expression had a door around it. A dataset editor with no SQL Lab access could submit `(SELECT secret FROM protected_table LIMIT 1) || :value` and read the answer out of `emitted_predicate`. `validate_stored_expression` now runs before the probe, inside `preview_partition_mapping` rather than at the route, so a second caller cannot forget it. **A probed value could not be rendered.** The probe reads its results out of a pandas frame, so the canonical epoch transform returns a `numpy.int64` and a temporal one a `pandas.Timestamp`. SQLAlchemy has a literal renderer for neither: `sa.literal` infers `NullType` and raises `CompileError`, a 500 for the most ordinary mapping there is. Normalized at the probe boundary, so the query path gets the same treatment, with pandas' missing-value sentinels folded into `None` -- `NaT` has no renderer either, and a transform returning nothing for an input it cannot convert is the NULL case the mirror already admits. The tests patch `Database.get_df` rather than `evaluate_transform`; stubbing the evaluator hands back a plain `int` and never touches a frame, which is why this was green. **The fixed window was not fixed.** It now comes from the key -- one bucket per window -- rather than from the entry's lifetime, because the TTL could not carry that promise on either backend. cachelib's generic `inc` is a read-modify-write whose `set` restamps `CACHE_DEFAULT_TIMEOUT`, a day by default, so on SimpleCache retrying after the budget was spent kept renewing a day-long lockout. On Redis `INCR` leaves the TTL alone, but a key expiring between a losing `add` and the `inc` is recreated with no TTL at all, and the owner was then 429'd permanently. A counter that outlives its bucket is now simply never read again. **Two API-surface fixes.** `partition_mapping_preview` was missing from `method_permission_name`, so `@protect()` demanded a bespoke `can_partition_mapping_preview` permission: a custom role with `can_write` could store a mapping and not preview it. And the `429` pointed at the shared "Bad request" response while the `403` from `raise_for_editorship` was undocumented, so a generated client read a throttled caller as having sent bad input. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…hema The preview request repeated the literal the typed column field and the import schema enforce through `MAX_TRANSFORM_LENGTH`. Three copies of one number is one rule stated three times, free to drift. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Closing in favour of #43870, which now carries the whole feature against Nothing is lost. The commits are unchanged and still in #43870's history, so this stage is still reviewable on its own, and the 6 unresolved comments from this PR are reproduced in an inventory comment there — each with a link back to the original thread and the commit that addressed it. They were all addressed in the review pass of 2026-10-01; they show as unresolved here only because the threads were never clicked shut. @sadpandajoe @rusackas — sorry for the churn. If you would rather keep reviewing stage by stage, say so and I will reopen; the branches are all still there. |
Stack (review bottom-up):
SUMMARY
Third of four. Adds the server-side half of the dataset editor experience, plus the frontend types and save-payload wiring the editor UI will need.
The preview endpoint shows an owner the predicate their transform would emit:
It fires a real warehouse query from a text input, so the order of its guards is the point:
Guarded by
@protect()plus per-objectraise_for_editorship, and gated on the feature flag.Frontend — plumbing, not UI:
partition_column/partition_mapped_columnin the dataset save payload, andpartition_value_transform/partition_transform_is_monotonicin the per-column whitelist. Anything outside that whitelist is silently dropped on save, so this is load-bearing.clearDanglingPartitionMapping, applied after a metadata sync. The backend clears a dangling mapping too on the authoritativeoverride_columnspath (PR 1); this keeps the editor's own state honest in between, so an owner is never looking at a mapping pointing at a column the table no longer has.The visual editor controls — the partition column select, the
PARTITIONtag, the row-expand section with the transform input and "Transform preserves ordering" checkbox — are not in this PR.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A — no rendered UI in this PR.
TESTING INSTRUCTIONS
The preview tests assert the guard ordering, not just the outcomes: several stub the probe with
side_effect=AssertionError("probe must not run"), so they fail if validation ever stops short-circuiting ahead of the engine call.ADDITIONAL INFORMATION
PARTITION_FILTER_MAPPING(off by default)