codeant-ai-for-open-source[bot] commented on code in PR #41334:
URL: https://github.com/apache/superset/pull/41334#discussion_r3458691428
##########
tests/unit_tests/common/test_time_shifts.py:
##########
@@ -211,6 +214,91 @@ def test_join_offset_dfs_with_month_granularity():
assert_frame_equal(expected, result)
+def test_join_offset_dfs_full_range_keeps_historical_tail():
Review Comment:
**Suggestion:** Add an explicit return type annotation to this newly added
test function so it complies with the requirement that new Python functions are
fully typed. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is a newly added Python function in changed code, and it lacks an
explicit return type annotation. The custom rule requires new Python functions
to be fully typed, so this is a real violation.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=c06153d54ae84dbdb259e4e6c908001c&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=c06153d54ae84dbdb259e4e6c908001c&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:** tests/unit_tests/common/test_time_shifts.py
**Line:** 217:217
**Comment:**
*Custom Rule: Add an explicit return type annotation to this newly
added test function so it complies with the requirement that new Python
functions are fully typed.
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%2F41334&comment_hash=3b8485c6a973edbe4adad7d46ccbff3bbc62783ba411ea892baf1040a8abd97f&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41334&comment_hash=3b8485c6a973edbe4adad7d46ccbff3bbc62783ba411ea892baf1040a8abd97f&reaction=dislike'>👎</a>
##########
tests/unit_tests/common/test_time_shifts.py:
##########
@@ -211,6 +214,91 @@ def test_join_offset_dfs_with_month_granularity():
assert_frame_equal(expected, result)
+def test_join_offset_dfs_full_range_keeps_historical_tail():
+ """
+ With full_range=True the offset (historical) series keeps its full time
range
+ even when the main series ends earlier.
+
+ Simulates "today so far" (main, ends at 01:00) compared against "1 day ago"
+ (a complete prior day, runs to 02:00). The 02:00 historical point must
survive
+ and be aligned onto today's axis, with the main metric left null there.
+ """
+ # Main series: today, only two hours of data so far.
+ df = DataFrame(
+ {
+ "A": [Timestamp("2021-01-02 00:00"), Timestamp("2021-01-02
01:00")],
+ "V": [1.0, 2.0],
+ }
+ )
+ # Offset series: the full prior day (already renamed metric column "B").
+ offset_df = DataFrame(
+ {
+ "A": [
+ Timestamp("2021-01-01 00:00"),
+ Timestamp("2021-01-01 01:00"),
+ Timestamp("2021-01-01 02:00"),
+ ],
+ "B": [10.0, 20.0, 30.0],
+ }
+ )
+ offset_dfs = {"1 day ago": offset_df}
+ time_grain = TimeGrain.HOUR
+ join_keys = ["A"]
+
+ expected = DataFrame(
+ {
+ "A": [
+ Timestamp("2021-01-02 00:00"),
+ Timestamp("2021-01-02 01:00"),
+ Timestamp("2021-01-02 02:00"),
+ ],
+ "V": [1.0, 2.0, None],
+ "B": [10.0, 20.0, 30.0],
+ }
+ )
+
+ result = query_context_processor.join_offset_dfs(
+ df, offset_dfs, time_grain, join_keys, full_range=True
+ )
+
+ assert_frame_equal(expected, result)
+
+
+def test_join_offset_dfs_full_range_disabled_truncates_historical():
Review Comment:
**Suggestion:** Add an explicit return type annotation to this newly added
test function to satisfy the typing rule for new Python code. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
This is also a newly added Python function in the modified file, and it has
no return type annotation. That directly violates the rule that new Python code
should be fully typed.
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=16344a538e3d463e9963caf8de2b68c0&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=16344a538e3d463e9963caf8de2b68c0&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:** tests/unit_tests/common/test_time_shifts.py
**Line:** 267:267
**Comment:**
*Custom Rule: Add an explicit return type annotation to this newly
added test function to satisfy the typing rule for new Python code.
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%2F41334&comment_hash=d88fe28fe9d1324499dec715304a54e21a5b0f133d3cf1a28be5fcc57543715b&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41334&comment_hash=d88fe28fe9d1324499dec715304a54e21a5b0f133d3cf1a28be5fcc57543715b&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]