codeant-ai-for-open-source[bot] commented on code in PR #42609:
URL: https://github.com/apache/superset/pull/42609#discussion_r3680818076
##########
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)
Review Comment:
**Suggestion:** The new resolver only runs when `exec_post_processing` is
called, but the semantic-layer execution path skips that method whenever
`result.df.empty`. Consequently, an empty query cannot be expanded into the
requested full time range, so enabling full-range zero filling still returns an
empty frame instead of the expected zero buckets for that path. Apply the
resample operation for this option even when the query result has no rows.
[incomplete implementation]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Empty semantic-layer ranges remain unexpanded.
- ⚠️ Full-range zero filling fails when no source rows exist.
- ⚠️ Affected charts cannot display requested empty periods.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ba65ae606bc64a049974f7f11e83d902&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=ba65ae606bc64a049974f7f11e83d902&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/common/query_object.py
**Line:** 539:541
**Comment:**
*Incomplete Implementation: The new resolver only runs when
`exec_post_processing` is called, but the semantic-layer execution path skips
that method whenever `result.df.empty`. Consequently, an empty query cannot be
expanded into the requested full time range, so enabling full-range zero
filling still returns an empty frame instead of the expected zero buckets for
that path. Apply the resample operation for this option even when the query
result has no rows.
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%2F42609&comment_hash=94bffbcc1c6ff3e247e76b77349c16ac10b03cfa5a6b5b0c12d591bb81434b39&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42609&comment_hash=94bffbcc1c6ff3e247e76b77349c16ac10b03cfa5a6b5b0c12d591bb81434b39&reaction=dislike'>👎</a>
##########
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)
Review Comment:
**Suggestion:** These `setdefault` calls preserve client-supplied
`time_range_start` and `time_range_end` instead of forcing the resolved query
boundaries. Since post-processing options are accepted as an unrestricted
dictionary, a caller can request an arbitrarily large range and cause pandas to
allocate an unexpectedly large resampled frame. Remove client-provided
boundaries or overwrite them with `self.from_dttm` and `self.to_dttm`.
[performance]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Resample requests can allocate unexpectedly large DataFrames.
- ⚠️ Query workers may experience memory pressure or slow responses.
- ⚠️ The requested query range no longer bounds post-processing work.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=59bf4d58ce7a47f78f98dac374d3688d&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=59bf4d58ce7a47f78f98dac374d3688d&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/common/query_object.py
**Line:** 561:562
**Comment:**
*Performance: These `setdefault` calls preserve client-supplied
`time_range_start` and `time_range_end` instead of forcing the resolved query
boundaries. Since post-processing options are accepted as an unrestricted
dictionary, a caller can request an arbitrarily large range and cause pandas to
allocate an unexpectedly large resampled frame. Remove client-provided
boundaries or overwrite them with `self.from_dttm` and `self.to_dttm`.
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%2F42609&comment_hash=08c19c5aebab75c700eed2988dab0854b57eb168afb7dc408921110900597c83&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42609&comment_hash=08c19c5aebab75c700eed2988dab0854b57eb168afb7dc408921110900597c83&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: [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]