Copilot commented on code in PR #42609:
URL: https://github.com/apache/superset/pull/42609#discussion_r3684880177
##########
superset/common/query_object.py:
##########
@@ -536,5 +536,28 @@ def exec_post_processing(self, df: DataFrame) -> DataFrame:
)
)
options = post_process.get("options", {})
+ if operation == "resample":
Review Comment:
The translation string uses the "%(operation)s" placeholder, but the
interpolation passes `type=operation`. With Flask-Babel this will raise a
KeyError while trying to format the message, masking the intended
InvalidPostProcessingError.
##########
superset/common/query_object.py:
##########
@@ -536,5 +536,28 @@ def exec_post_processing(self, df: DataFrame) -> DataFrame:
)
)
options = post_process.get("options", {})
+ if operation == "resample":
+ options = self._resolve_resample_options(options)
df = getattr(pandas_postprocessing, operation)(df, **options)
return df
+
+ def _resolve_resample_options(self, options: dict[str, Any]) -> dict[str,
Any]:
+ """
+ Translate the `fill_time_range` flag into explicit resample boundaries.
+
+ Clients cannot supply the boundaries themselves because time ranges
may be
+ expressed in natural language (e.g. `Last week`) and are only resolved
into
+ concrete datetimes server side.
+
+ :param options: Options of the `resample` post processing operation.
+ :return: Options with the boundaries of the queried time range applied.
+ """
+ if not options.get("fill_time_range"):
+ return options
+
+ resolved = {
+ key: value for key, value in options.items() if key !=
"fill_time_range"
+ }
+ resolved.setdefault("time_range_start", self.from_dttm)
+ resolved.setdefault("time_range_end", self.to_dttm)
+ return resolved
Review Comment:
`fill_time_range` is documented as being resolved server-side to the query’s
actual `from_dttm`/`to_dttm`, but `setdefault` allows clients to override
`time_range_start`/`time_range_end` if they include those keys. This makes the
behavior inconsistent with the intent and can allow padding outside the
resolved query window.
--
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]