codeant-ai-for-open-source[bot] commented on code in PR #44526:
URL: https://github.com/apache/superset/pull/44526#discussion_r4093799202
##########
superset/common/query_context_factory.py:
##########
@@ -275,6 +275,27 @@ def _apply_granularity( # noqa: C901
query_object.granularity = main_dttm_col
return
+ # A ``query_context`` saved by an older version carries no
+ # ``granularity`` of its own and no x-axis at all: its temporal column
+ # survives only in ``form_data`` as ``granularity_sqla``. Explore
+ # rebuilds the query from ``form_data`` on every render and never
+ # notices, but every other consumer replays the stored query verbatim
+ # and fails the ``not granularity and is_timeseries`` check in
+ # ``models.helpers``. The absent x-axis is what distinguishes this
shape
+ # from a modern chart, so it is tested first. Recover the column the
way
+ # Explore effectively does, preferring what the chart saved over the
+ # dataset default.
+ if (
+ not x_axis
+ and query_object.granularity is None
+ and query_object.is_timeseries
+ ):
+ legacy_granularity = (form_data or {}).get("granularity_sqla") or
getattr(
+ datasource, "main_dttm_col", None
+ )
+ if legacy_granularity in temporal_columns:
+ query_object.granularity = legacy_granularity
Review Comment:
**Suggestion:** When a legacy query has a temporal filter but no
`time_range`, this assignment activates later filter removal without adding a
replacement, silently dropping the only temporal restriction.
**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=93569b5aacbc481cb80dbcec038ca113&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=93569b5aacbc481cb80dbcec038ca113&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/common/query_context_factory.py
**Line:** 288:297
**Comment:**
*Logic Error: When a legacy query has a temporal filter but no
`time_range`, this assignment activates later filter removal without adding a
replacement, silently dropping the only temporal restriction.
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%2F44526&comment_hash=a82e0a73972e86bd17dbc57cc4dbdaf3d128dac2dc71ec6cb258eddcd3c87de7&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44526&comment_hash=a82e0a73972e86bd17dbc57cc4dbdaf3d128dac2dc71ec6cb258eddcd3c87de7&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]