korbit-ai[bot] commented on code in PR #33224:
URL: https://github.com/apache/superset/pull/33224#discussion_r2057194629
##########
superset/migrations/shared/migrate_viz/base.py:
##########
@@ -113,14 +114,33 @@ def _migrate_temporal_filter(self, rv_data: dict[str,
Any]) -> None:
}
if isinstance(granularity_sqla, dict):
- temporal_filter["comparator"] = None
- temporal_filter["expressionType"] = "SQL"
- temporal_filter["subject"] = granularity_sqla["label"]
- temporal_filter["sqlExpression"] =
granularity_sqla["sqlExpression"]
-
- rv_data["adhoc_filters"] = (rv_data.get("adhoc_filters") or []) + [
- temporal_filter
- ]
+ since, until = get_since_until(time_range=time_range)
+ if not since and not until:
+ temporal_filter = {}
+ else:
+ temporal_filter["comparator"] = None
+ temporal_filter["expressionType"] = "SQL"
+ temporal_filter["subject"] = granularity_sqla["label"]
+
+ start_date = since.isoformat() if since else None
+ end_date = until.isoformat() if until else None
+ if start_date and end_date:
+ temporal_filter["sqlExpression"] = (
+ f"{granularity_sqla['sqlExpression']} >=
'{start_date}' AND "
+ f"{granularity_sqla['sqlExpression']} < '{end_date}'"
Review Comment:
### Exclusive End Date Boundary <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The temporal filter uses '<' for end date comparison which may exclude data
points exactly at the end date boundary.
###### Why this matters
Users may expect data points exactly at the end date to be included in their
results, but the current logic excludes them, potentially causing missing data
at the boundaries.
###### Suggested change ∙ *Feature Preview*
Change the end date comparison to use '<=' to include data points at the end
date boundary:
```python
f"{granularity_sqla['sqlExpression']} <= '{end_date}'"
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c09f96b6-34ef-455a-9905-d4fcb72babfa/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c09f96b6-34ef-455a-9905-d4fcb72babfa?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c09f96b6-34ef-455a-9905-d4fcb72babfa?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c09f96b6-34ef-455a-9905-d4fcb72babfa?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/c09f96b6-34ef-455a-9905-d4fcb72babfa)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:b55c38a4-8891-45fc-aabc-37d51913b75d -->
[](b55c38a4-8891-45fc-aabc-37d51913b75d)
--
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]