You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "hughhhh (via GitHub)" <gi...@apache.org> on 2026/09/01 12:57:38 UTC
[PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
hughhhh opened a new pull request, #43759:
URL: https://github.com/apache/superset/pull/43759
### 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:
```
POST /api/v1/dataset/<pk>/partition_mapping/preview/
{ "mapped_column": "event_time",
"value_transform": "unix_timestamp(:value)",
"sample_value": "2026-01-15 00:00:00" }
→ { "valid": true, "emitted_predicate": "dt_epoch >= 1768435200" }
```
It fires a real warehouse query from a text input, so the order of its guards is the point:
1. **Validate first, probe second.** Parse and denylist checks run before anything reaches the engine, so a half-typed transform — by definition unparseable, and most of what a text input produces — costs zero queries.
2. **Shared cache.** Same evaluator and probe cache as the query path, so preview and runtime cannot drift and a previewed transform warms the chart path for free.
3. **Server-side rate limit**, per user and dataset. Debouncing on the client is a courtesy, not a guard: a held keydown, or a few owners with the editor open, is sustained load on a production cluster.
Guarded by `@protect()` plus per-object `raise_for_editorship`, and gated on the feature flag.
**Frontend — plumbing, not 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, so this is load-bearing.
- `clearDanglingPartitionMapping`, applied after a metadata sync. The backend clears a dangling mapping too on the authoritative `override_columns` path (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.
- A test pinning down that a sync **preserves** a hand-written transform — 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 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
```bash
pytest tests/unit_tests/datasets/partition_mapping_preview_test.py
cd superset-frontend && npx jest src/components/Datasource
```
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
- [ ] Has associated issue:
- [x] Required feature flags: `PARTITION_FILTER_MAPPING` (off by default)
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [x] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh commented on PR #43759:
URL: https://github.com/apache/superset/pull/43759#issuecomment-5943832599
Closing in favour of **#43870**, which now carries the whole feature against `master` rather than the five-PR stack this was the preview endpoint and editor plumbing of.
Nothing is lost. The commits are unchanged and still in #43870's history, so this stage is still reviewable on its own, and **the 6 unresolved comments from this PR are reproduced in [an inventory comment there](https://github.com/apache/superset/pull/43870#issuecomment-5943828536)** — 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4136778878
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `0a01182`.
Added `Length` validators to bound `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `0a01182`.
The rate limiter now sets the timeout only when `backend.add` creates a new counter; subsequent requests use `backend.inc` without resetting the window.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh closed pull request #43759: feat(datasets): add partition mapping preview endpoint and editor plumbing
URL: https://github.com/apache/superset/pull/43759
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r3942064511
##########
superset/datasets/api.py:
##########
@@ -149,6 +157,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
Review Comment:
This read-then-set counter is not atomic. Concurrent preview requests can all read the same value below the limit, each write the same incremented value, and all reach the warehouse probe, so a burst can bypass the query-load guard this endpoint relies on. Could this use an atomic cache increment/limit operation and cover concurrent requests?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #43759:
URL: https://github.com/apache/superset/pull/43759#issuecomment-5494378013
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | c7a6548b4a0a62c0e1c4481a35df3f02b2cd498c |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a96cbc21b42f80008d81307 |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-43759--superset-docs-preview.netlify.app](https://deploy-preview-43759--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpBCoAgEEDRu8w6yTTMukHHUEczqBzEiojunn_1F-8FymmnAhNAAzabw8X68VxiraWwM8ko-2v1NzMHMo9rSbla9LSlZ8aqlRmVs050thdBc8416k7yAb4f) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-43759--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4089581009
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `2897e1f`.
Added marshmallow length validators limiting `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `2897e1f`.
Changed rate-limit initialization to use `backend.add` with the 60-second timeout only for the first request, followed by `backend.inc` without resetting the TTL.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4089716833
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `8ab5bba`.
Added marshmallow length validators limiting `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `8ab5bba`.
Changed rate-limit initialization to use `backend.add` with the 60-second timeout only for the first request, followed by `backend.inc` without resetting the TTL.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4125845471
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `2be9485`.
Length validators now bound `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `2be9485`.
The rate limiter now sets the cache TTL only when `backend.add` creates the counter; subsequent requests use `inc` without resetting the window.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4135902467
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `45ab3ff`.
Added `Length` validators to bound `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `45ab3ff`.
The rate limiter now sets the timeout only when `backend.add` creates a new counter; subsequent requests use `backend.inc` without resetting the window.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4107580342
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `8ab5bba`.
Added marshmallow length validators limiting `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `8ab5bba`.
Changed rate-limit initialization to use `backend.add` with the 60-second timeout only for the first request, followed by `backend.inc` without resetting the TTL.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #43759:
URL: https://github.com/apache/superset/pull/43759#issuecomment-5647767800
@sadpandajoe's thread on the rate limiter is still open, and it seems correct. `get` then `set` isn't atomic, so a burst of concurrent previews can all read the same count and slip past the limit, which is what this guard exists for. Worth swapping to an atomic incr on the cache backend instead of get+threshold+set.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4155597487
##########
superset/connectors/sqla/partition_mapping.py:
##########
@@ -772,6 +772,87 @@ def is_transform_active(transform: str | None, engine: str) -> bool:
return not validate_transform(transform, engine)
+def preview_partition_mapping(
+ datasource: SqlaTable,
+ *,
+ mapped_column: str,
+ value_transform: str | None,
+ sample_value: str,
+) -> dict[str, Any]:
+ """
+ Evaluate a candidate mapping and describe the predicate it would emit.
+
+ Shares the evaluator -- and therefore the probe cache -- with the query
+ path, so preview and runtime cannot drift and a previewed transform warms
+ the chart path for free.
+
+ Validation runs first and the engine second: a half-typed transform is by
+ definition unparseable, so most of what a text input produces costs zero
+ queries.
+ """
+ partition_column = datasource.partition_column
+ if not partition_column:
+ return {"valid": False, "error": _("No partition column is set.")}
+
+ column_names = {str(column.column_name) for column in datasource.columns}
+ if mapped_column not in column_names:
+ return {
+ "valid": False,
+ "error": _("%(name)s is not a column on this dataset.", name=mapped_column),
+ }
+
+ engine = datasource.database.backend
+ for issue in validate_partition_mapping(
+ column_names=column_names,
+ partition_column=str(partition_column),
+ partition_mapped_column=mapped_column,
+ main_dttm_col=datasource.main_dttm_col,
+ transform=value_transform,
+ engine=engine,
+ ):
+ return {"valid": False, "error": str(issue.message)}
+
+ evaluated = evaluate_transform(
+ datasource.database,
+ datasource.catalog,
+ datasource.schema,
+ cast(str, value_transform),
+ [sample_value],
+ )
+ if evaluated is None:
+ return {
+ "valid": False,
+ "error": _("The transform could not be evaluated against the database."),
+ }
+
+ return {
+ "valid": True,
+ "emitted_predicate": (
+ f"{datasource.quote_identifier(str(partition_column))} >= "
+ f"{_render_literal(datasource.database, evaluated[0])}"
+ ),
+ }
+
+
+def _render_literal(database: Database, value: Any) -> str:
+ """
+ Render a probed value the way it appears in the generated SQL.
+
+ Compiled by the dialect rather than formatted by hand. A probe returns
+ whatever the warehouse gave it -- an epoch integer, a date, a NULL for an
+ input the transform could not convert -- and only the dialect knows how each
+ of those is written. `str()` would render a NULL as `None` and leave a date
+ unquoted, neither of which is SQL; hand-rolled quote-doubling would only
+ ever have been right for strings.
+ """
+ return str(
+ sa.literal(value).compile(
Review 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`?
##########
superset/connectors/sqla/partition_mapping.py:
##########
@@ -772,6 +772,87 @@ def is_transform_active(transform: str | None, engine: str) -> bool:
return not validate_transform(transform, engine)
+def preview_partition_mapping(
+ datasource: SqlaTable,
+ *,
+ mapped_column: str,
+ value_transform: str | None,
+ sample_value: str,
+) -> dict[str, Any]:
+ """
+ Evaluate a candidate mapping and describe the predicate it would emit.
+
+ Shares the evaluator -- and therefore the probe cache -- with the query
+ path, so preview and runtime cannot drift and a previewed transform warms
+ the chart path for free.
+
+ Validation runs first and the engine second: a half-typed transform is by
+ definition unparseable, so most of what a text input produces costs zero
+ queries.
+ """
+ partition_column = datasource.partition_column
+ if not partition_column:
+ return {"valid": False, "error": _("No partition column is set.")}
+
+ column_names = {str(column.column_name) for column in datasource.columns}
+ if mapped_column not in column_names:
+ return {
+ "valid": False,
+ "error": _("%(name)s is not a column on this dataset.", name=mapped_column),
+ }
+
+ engine = datasource.database.backend
+ for issue in validate_partition_mapping(
+ column_names=column_names,
+ partition_column=str(partition_column),
+ partition_mapped_column=mapped_column,
+ main_dttm_col=datasource.main_dttm_col,
+ transform=value_transform,
+ engine=engine,
+ ):
+ return {"valid": False, "error": str(issue.message)}
+
+ evaluated = evaluate_transform(
Review 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?
##########
superset/datasets/api.py:
##########
@@ -158,6 +163,51 @@
)
+#: How long one preview budget lasts, in seconds.
+PREVIEW_RATE_LIMIT_WINDOW = 60
+
+
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+
+ Counting is `add` then `inc` rather than read-then-write, which buys two
+ things a `get`/`set` pair cannot. It is atomic where it matters -- on Redis
+ those are `SETNX` and `INCR`, so concurrent previews cannot each read the
+ same sub-limit value and all be let through. And the window is genuinely
+ fixed: only `add` sets a lifetime, so the budget expires a minute after the
+ *first* request rather than a minute after the most recent one, which is
+ what the name promises. (`INCR` leaves the TTL alone; a backend whose `inc`
+ is a read-modify-write may restore its own default lifetime instead, which
+ throttles for longer rather than shorter.)
+
+ Both calls go to the cachelib backend rather than the Flask-Caching wrapper
+ around it, which proxies `add` but not `inc`.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ backend = cache_manager.cache.cache
+ try:
+ 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)
Review 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?
##########
superset-frontend/src/components/Datasource/DatasourceModal/index.tsx:
##########
@@ -231,6 +233,10 @@ const DatasourceModal: FunctionComponent<DatasourceModalProps> = ({
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,
Review 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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4155609394
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
Agreed—the current `inc()` still resets the expiry on SimpleCache and other read-modify-write backends, using the default cache timeout rather than 60 seconds. With the one-day default, retries after the budget is spent keep renewing a day-long lockout; could the fixed-window behavior be enforced for supported backends or the Redis-only requirement be explicit?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4054141942
##########
superset/connectors/sqla/partition_mapping.py:
##########
@@ -651,6 +651,73 @@ def validate_transform(
return []
+def preview_partition_mapping(
+ datasource: SqlaTable,
+ *,
+ mapped_column: str,
+ value_transform: str | None,
+ sample_value: str,
+) -> dict[str, Any]:
+ """
+ Evaluate a candidate mapping and describe the predicate it would emit.
+
+ Shares the evaluator -- and therefore the probe cache -- with the query
+ path, so preview and runtime cannot drift and a previewed transform warms
+ the chart path for free.
+
+ Validation runs first and the engine second: a half-typed transform is by
+ definition unparseable, so most of what a text input produces costs zero
+ queries.
+ """
+ partition_column = datasource.partition_column
+ if not partition_column:
+ return {"valid": False, "error": _("No partition column is set.")}
+
+ column_names = {str(column.column_name) for column in datasource.columns}
+ if mapped_column not in column_names:
+ return {
+ "valid": False,
+ "error": _("%(name)s is not a column on this dataset.", name=mapped_column),
+ }
+
+ engine = datasource.database.backend
+ for issue in validate_partition_mapping(
+ column_names=column_names,
+ partition_column=str(partition_column),
+ partition_mapped_column=mapped_column,
+ main_dttm_col=datasource.main_dttm_col,
+ transform=value_transform,
+ engine=engine,
+ ):
+ return {"valid": False, "error": str(issue.message)}
+
+ evaluated = evaluate_transform(
+ datasource.database,
+ datasource.catalog,
+ datasource.schema,
+ cast(str, value_transform),
+ [sample_value],
+ )
+ if evaluated is None:
+ return {
+ "valid": False,
+ "error": _("The transform could not be evaluated against the database."),
+ }
+
+ return {
+ "valid": True,
+ "emitted_predicate": (f"{partition_column} >= {_render_literal(evaluated[0])}"),
Review Comment:
**Suggestion:** `partition_column` is interpolated without identifier quoting, so columns containing spaces or reserved words produce invalid preview predicates.
**Assessment:** 🟠 `Major` · 🔁 `Occurrence: Sometimes` · 🏷️ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=3040cf7986ba4aedb0a4172f61882e6c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=3040cf7986ba4aedb0a4172f61882e6c&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/connectors/sqla/partition_mapping.py
**Line:** 709:709
**Comment:**
*Api Mismatch: `partition_column` is interpolated without identifier quoting, so columns containing spaces or reserved words produce invalid preview predicates.
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
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=68f216da6fe169c3f57b969b6d1d779f3ab9d7905cda771d5e26dffcdb3c82f6&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=68f216da6fe169c3f57b969b6d1d779f3ab9d7905cda771d5e26dffcdb3c82f6&reaction=dislike'>👎</a>
##########
superset/connectors/sqla/partition_mapping.py:
##########
@@ -651,6 +651,73 @@ def validate_transform(
return []
+def preview_partition_mapping(
+ datasource: SqlaTable,
+ *,
+ mapped_column: str,
+ value_transform: str | None,
+ sample_value: str,
+) -> dict[str, Any]:
+ """
+ Evaluate a candidate mapping and describe the predicate it would emit.
+
+ Shares the evaluator -- and therefore the probe cache -- with the query
+ path, so preview and runtime cannot drift and a previewed transform warms
+ the chart path for free.
+
+ Validation runs first and the engine second: a half-typed transform is by
+ definition unparseable, so most of what a text input produces costs zero
+ queries.
+ """
+ partition_column = datasource.partition_column
+ if not partition_column:
+ return {"valid": False, "error": _("No partition column is set.")}
+
+ column_names = {str(column.column_name) for column in datasource.columns}
+ if mapped_column not in column_names:
+ return {
+ "valid": False,
+ "error": _("%(name)s is not a column on this dataset.", name=mapped_column),
+ }
+
+ engine = datasource.database.backend
+ for issue in validate_partition_mapping(
+ column_names=column_names,
+ partition_column=str(partition_column),
+ partition_mapped_column=mapped_column,
+ main_dttm_col=datasource.main_dttm_col,
+ transform=value_transform,
+ engine=engine,
+ ):
+ return {"valid": False, "error": str(issue.message)}
+
+ evaluated = evaluate_transform(
+ datasource.database,
+ datasource.catalog,
+ datasource.schema,
+ cast(str, value_transform),
+ [sample_value],
+ )
+ if evaluated is None:
+ return {
+ "valid": False,
+ "error": _("The transform could not be evaluated against the database."),
+ }
+
+ return {
+ "valid": True,
+ "emitted_predicate": (f"{partition_column} >= {_render_literal(evaluated[0])}"),
+ }
+
+
+def _render_literal(value: Any) -> str:
+ """Render a probed value the way it appears in the generated SQL."""
+ if isinstance(value, str):
+ escaped = value.replace("'", "''")
+ return f"'{escaped}'"
+ return str(value)
+
Review Comment:
**Suggestion:** Non-string results are rendered with Python `str()`, so `NULL` becomes `None` and datetimes remain unquoted, producing invalid or misleading SQL.
**Assessment:** 🟠 `Major` · 🔁 `Occurrence: Sometimes` · 🏷️ `Type error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9534cc834c2c43c5b5710049ad0eef5f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9534cc834c2c43c5b5710049ad0eef5f&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/connectors/sqla/partition_mapping.py
**Line:** 713:719
**Comment:**
*Type Error: Non-string results are rendered with Python `str()`, so `NULL` becomes `None` and datetimes remain unquoted, producing invalid or misleading SQL.
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
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=40507ab0a32159c4ce196f8eb55f7e5a64920d6f69caca1647c8544f45ee3f43&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=40507ab0a32159c4ce196f8eb55f7e5a64920d6f69caca1647c8544f45ee3f43&reaction=dislike'>👎</a>
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
**Suggestion:** Resetting the 60-second timeout on every request makes this a sliding window, so sustained traffic can remain blocked indefinitely instead of using the documented fixed window.
**Assessment:** 🟠 `Major` · 🔁 `Occurrence: Sometimes` · 🏷️ `Logic error`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=9e008c7b4e2c46838a7d6edebe3d43c1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=9e008c7b4e2c46838a7d6edebe3d43c1&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/datasets/api.py
**Line:** 179:182
**Comment:**
*Logic Error: Resetting the 60-second timeout on every request makes this a sliding window, so sustained traffic can remain blocked indefinitely instead of using the documented fixed window.
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
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=acde1d9f9db46fe530acc7fddcda5c0c26697ef90e5b806bc6243acc25ef8d61&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=acde1d9f9db46fe530acc7fddcda5c0c26697ef90e5b806bc6243acc25ef8d61&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4113378322
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `ade9f01`.
Length validators now bound `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `ade9f01`.
The rate limiter now sets the cache TTL only when `backend.add` creates the counter; subsequent requests use `inc` without resetting the window.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4155616554
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
Agreed—the concern is valid. `backend.inc()` is not guaranteed to preserve the TTL on every cachelib backend; on read-modify-write implementations it can restamp the key, turning the fixed window into a sliding or unexpectedly long lockout.
The safest fix is to make this limiter Redis-only and use Redis-native operations:
- `SET key 1 NX EX 60` for the first request
- `INCR key` for subsequent requests, without calling `EXPIRE` again
- explicitly document Redis as a requirement for enforcing this limit
- fail open, as today, when Redis is unavailable or another backend is configured
Alternatively, use a dedicated fixed-window rate-limiter implementation that supports an atomic increment while preserving the original TTL. The current `add()`/`inc()` combination is not sufficient to guarantee the documented behavior across supported backends, so this should be corrected before merging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #43759:
URL: https://github.com/apache/superset/pull/43759#issuecomment-5494355936
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/43759?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `29.23077%` with `46 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 57.16%. Comparing base ([`3d7615a`](https://app.codecov.io/gh/apache/superset/commit/3d7615aa1c1261d95d85fa0bea74c6b933818b8b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`c7a6548`](https://app.codecov.io/gh/apache/superset/commit/c7a6548b4a0a62c0e1c4481a35df3f02b2cd498c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/43759?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/datasets/api.py](https://app.codecov.io/gh/apache/superset/pull/43759?src=pr&el=tree&filepath=superset%2Fdatasets%2Fapi.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvZGF0YXNldHMvYXBpLnB5) | 29.26% | [29 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43759?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/connectors/sqla/partition\_mapping.py](https://app.codecov.io/gh/apache/superset/pull/43759?src=pr&el=tree&filepath=superset%2Fconnectors%2Fsqla%2Fpartition_mapping.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvY29ubmVjdG9ycy9zcWxhL3BhcnRpdGlvbl9tYXBwaW5nLnB5) | 10.52% | [17 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/43759?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## hughhhh/pfm-2-query-rewrite #43759 +/- ##
===============================================================
- Coverage 57.20% 57.16% -0.04%
===============================================================
Files 2874 2874
Lines 164036 164098 +62
Branches 37846 37856 +10
===============================================================
- Hits 93837 93808 -29
- Misses 69304 69395 +91
Partials 895 895
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/43759/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/43759/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/43759/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.04% <29.23%> (-0.02%)` | :arrow_down: |
| [python](https://app.codecov.io/gh/apache/superset/pull/43759/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.04% <29.23%> (-0.07%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/43759?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43759:
URL: https://github.com/apache/superset/pull/43759#issuecomment-5494292690
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #43759:
URL: https://github.com/apache/superset/pull/43759#issuecomment-5554804088
<!-- Bito Reply -->
The concern regarding the lack of atomicity in the read-then-set counter is valid. Relying on a standard read-then-write operation in a distributed or multi-threaded environment can indeed lead to race conditions where concurrent requests bypass the intended query-load guard. To address this, using an atomic operation provided by your caching layer (such as Redis `INCR` or `SETNX` with an expiration) is the recommended approach. This ensures that the increment and limit check occur as a single, indivisible operation, effectively preventing the race condition described.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4107798016
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `6e03d09`.
Length validators now bound `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `6e03d09`.
The rate limiter now sets the cache TTL only when `backend.add` creates the counter; subsequent requests use `inc` without resetting the window.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4054141190
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
**Suggestion:** These fields have no length limits, so an authenticated editor can submit huge or parser-expensive text and exhaust application or warehouse resources.
**Assessment:** 🟠 `Major` · 🔁 `Occurrence: Sometimes` · 🏷️ `Security`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill) [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=87e43982085042678f646d1d3892c785&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=87e43982085042678f646d1d3892c785&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/datasets/schemas.py
**Line:** 522:534
**Comment:**
*Security: These fields have no length limits, so an authenticated editor can submit huge or parser-expensive text and exhaust application or warehouse 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
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=34a0f60b8e6934ef637b6e6fe993d6ea36b0fd7bccfb30de708d3e8f3872a0ec&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43759&comment_hash=34a0f60b8e6934ef637b6e6fe993d6ea36b0fd7bccfb30de708d3e8f3872a0ec&reaction=dislike'>👎</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "hughhhh (via GitHub)" <gi...@apache.org>.
hughhhh closed pull request #43759: feat(datasets): add partition mapping preview endpoint and editor plumbing
URL: https://github.com/apache/superset/pull/43759
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4158276846
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `7ee7f03`.
Added `Length` validators to bound `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `7ee7f03`.
The rate limiter now sets the timeout only when `backend.add` creates a new counter; subsequent requests use `backend.inc` without resetting the window.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4160174379
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `fb1ba20`.
Added `Length` validators to bound `mapped_column` and `sample_value` to 250 characters and `value_transform` to 1024 characters.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `fb1ba20`.
The rate limiter now sets the timeout only when `backend.add` creates a new counter; subsequent requests use `backend.inc` without resetting the window.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] feat(datasets): add partition mapping preview endpoint and editor plumbing [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #43759:
URL: https://github.com/apache/superset/pull/43759#discussion_r4161937745
##########
superset/datasets/schemas.py:
##########
@@ -516,6 +516,24 @@ class GetOrCreateDatasetSchema(Schema):
always_filter_main_dttm = fields.Boolean(load_default=False)
+class PartitionMappingPreviewSchema(Schema):
+ """Payload for the dataset editor's partition mapping preview panel."""
+
+ mapped_column = fields.String(
+ required=True,
+ metadata={"description": "Column whose filters would be mirrored"},
+ )
+ value_transform = fields.String(
+ required=True,
+ allow_none=True,
+ metadata={"description": "SQL expression containing a :value placeholder"},
+ )
+ sample_value = fields.String(
+ required=True,
+ metadata={"description": "Value to evaluate the transform at"},
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `ffa098b`.
Added length validation to `mapped_column` and `sample_value` with a 250-character limit, and to `value_transform` with `MAX_TRANSFORM_LENGTH`.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/datasets/api.py:
##########
@@ -153,6 +161,31 @@
)
+def _consume_preview_rate_limit(dataset_id: int) -> bool:
+ """
+ Fixed-window per-user, per-dataset throttle on the preview endpoint.
+
+ Debouncing on the client is a courtesy, not a guard: a held keydown, or a
+ handful of owners with the editor open, becomes sustained load on a
+ production cluster. Returns False once the window's budget is spent.
+ """
+ limit = app.config.get("PARTITION_TRANSFORM_PREVIEW_RATE_LIMIT", 30)
+ if not limit:
+ return True
+
+ user_id = get_user_id() or 0
+ key = f"partition_mapping_preview:{user_id}:{dataset_id}"
+ try:
+ used = cache_manager.cache.get(key) or 0
+ if used >= limit:
+ return False
+ cache_manager.cache.set(key, used + 1, timeout=60)
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and marked this thread resolved** as of `ffa098b`.
The rate-limit key now includes a time bucket derived from `PREVIEW_RATE_LIMIT_WINDOW`, so each fixed window uses a separate counter instead of renewing the timeout on every request.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it open.</sub>
<!-- codeant-auto-resolve-reply -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org