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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]