AmoghAtreya commented on code in PR #42609:
URL: https://github.com/apache/superset/pull/42609#discussion_r3688670842


##########
superset/utils/pandas_postprocessing/resample.py:
##########
@@ -46,6 +171,20 @@ def resample(
             _("Resample method should be in ") + ", ".join(RESAMPLE_METHOD) + 
"."
         )
 
+    tz = df.index.tz
+    df = _pad_to_time_range(
+        df,
+        _coerce_bound(time_range_start, tz),
+        _coerce_bound(time_range_end, tz),
+    )
+    # An empty frame with no time-range anchors has nothing to bin. Returning
+    # early keeps the DatetimeIndex intact; ``resample`` on a zero-length index
+    # would otherwise degrade it to an object Index.
+    if df.empty:
+        return df
+
+    _validate_bucket_count(df.index.min(), df.index.max(), rule)

Review Comment:
   Just fixed that!
   
   Here is how I was able to resolve it: 
   * **Scoped Bucket Validation:** Scoped `_validate_bucket_count` so it 
strictly executes on the padded path (when `time_range_start` or 
`time_range_end` is supplied). Plain `resample()` operations on un-bounded 
historical data are left untouched.
   * **Raised & Configurable Cap:** Raised `MAX_RESAMPLE_BUCKETS` to `50_000` 
in `superset/config.py` and made it configurable via `current_app.config` 
(following the existing fallback pattern used for Prophet).
   * **Documentation:** Added an entry to `UPDATING.md` documenting the new 
`MAX_RESAMPLE_BUCKETS` configuration option.
   * **Test Coverage:** Added and updated unit tests verifying that:
     - Bounded queries exceeding the 50k limit raise 
`InvalidPostProcessingError`.
     - Unbounded queries over large historical ranges (e.g. daily points from 
1990 to 2020 spanning >10,000 buckets) execute successfully without raising 
errors.
   
   All 22 resample unit tests are passing as intended.



-- 
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]

Reply via email to