You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "msyavuz (via GitHub)" <gi...@apache.org> on 2026/06/23 09:45:28 UTC

[PR] feat(explore): add full-range option for time-shift comparison [superset]

msyavuz opened a new pull request, #41334:
URL: https://github.com/apache/superset/pull/41334

   ### SUMMARY
   
   The default ECharts line chart left-joins each time-shifted comparison series onto the *current* period's rows, so a historical series gets truncated to wherever the main series ends (e.g. today's partial day). The deprecated NVD3 line chart kept comparison series at their full range — which users relied on for intraday "today vs prior days" overlays.
   
   This adds an opt-in **Show full range for time shift** control (Data → Advanced analytics → Time comparison). When enabled, offset series are outer-joined and their x-axis rebuilt so each comparison line spans its full period while the current-period line stops at its last data point. Default off — existing behavior is byte-for-byte unchanged. The option is wired only into the regular timeseries query builder, so it is hidden on Mixed charts where it would be a no-op.
   
   ### BEFORE/AFTER
   
   - **Before / option off:** the historical comparison line stops where the main series stops.
   - **After / option on:** the historical (dotted) line spans the full prior period; the current-period line still stops at its last data point.
   
   ### TESTING INSTRUCTIONS
   
   - Line chart on an intraday dataset: time-column X-axis, Hour grain, Time shift = `1 day ago`. Toggle **Show full range for time shift**: off → both lines end together; on → the comparison line continues to end of the prior day. The `/api/v1/chart/data` response gains trailing rows where the main metric is `null` and the `… 1 day ago` metric is populated.
   - `pytest tests/unit_tests/common/test_time_shifts.py` (new cases cover full-range on vs off).
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue: No
   - [ ] Required feature flags: No — gated entirely by the per-chart control, default off
   - [x] Changes UI — adds one checkbox under Advanced analytics → Time comparison
   - [ ] Includes DB Migration: No — backend adds an optional query field only
   - [x] Introduces new feature or API — new `time_compare_full_range` query-object field + control
   - [ ] Removes existing feature or API: No
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(explore): add full-range option for time-shift comparison [superset]

Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
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>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](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) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](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>
   
   [![Fix in Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](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) [![Fix in VSCode Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(explore): add full-range option for time-shift comparison [superset]

Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz merged PR #41334:
URL: https://github.com/apache/superset/pull/41334


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(explore): add full-range option for time-shift comparison [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41334:
URL: https://github.com/apache/superset/pull/41334#issuecomment-4781569615

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
   
   <details>
   <summary>
   Bito Usage Guide
   </summary>
   
   **Commands**
         
   Type the following command in the pull request comment and save the comment.
         
   - `/review` - Manually triggers a full AI review.
   
   - `/pause` - Pauses automatic reviews on this pull request.
   - `/resume` - Resumes automatic reviews.
   - `/resolve` - Marks all Bito-posted review comments as resolved.
   - `/abort` - Cancels all in-progress reviews.
   
         
   Refer to the <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
         
   **Configuration**
   
   This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
         
   **Documentation & Help**
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
   - <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
   
   </details>
   


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(explore): add full-range option for time-shift comparison [superset]

Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #41334:
URL: https://github.com/apache/superset/pull/41334#issuecomment-4777919373

   ### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
   
   
   |  Name | Link |
   |:-:|------------------------|
   |<span aria-hidden="true">🔨</span> Latest commit | 8d5a6a99180cd732126ca0e234ed50e2b2aade16 |
   |<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/6a3a55b91e00ad0008afef61 |
   |<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-41334--superset-docs-preview.netlify.app](https://deploy-preview-41334--superset-docs-preview.netlify.app) |
   |<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />![QR Code](https://app.netlify.com/qr-code/eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cmwiOiJodHRwczovL2RlcGxveS1wcmV2aWV3LTQxMzM0LS1zdXBlcnNldC1kb2NzLXByZXZpZXcubmV0bGlmeS5hcHAifQ.Nm8dYupcPNsDi9N0EUbrsKgSL3BF2gBfhwRWWA7EQuw)<br /><br />_Use your smartphone camera to open QR code link._</details> |
   |<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcpBDkAwEADAv-xZ022E4AeesXRXJa02lATxd73NYV5IewwpwwBQwbTTNrvicNx0nY8WpqzzGlgdbpWs5PRelbRw2ZaTj_doy2-ppqaZesOIZBGxI2FpDXw_) |
   ---
   <!-- [superset-docs-preview Preview](https://deploy-preview-41334--superset-docs-preview.netlify.app) -->
   _To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(explore): add full-range option for time-shift comparison [superset]

Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #41334:
URL: https://github.com/apache/superset/pull/41334#issuecomment-4777896973

   AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


Re: [PR] feat(explore): add full-range option for time-shift comparison [superset]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #41334:
URL: https://github.com/apache/superset/pull/41334#issuecomment-4777993134

   ## [Codecov](https://app.codecov.io/gh/apache/superset/pull/41334?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `30.43478%` with `16 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 55.58%. Comparing base ([`8b430ca`](https://app.codecov.io/gh/apache/superset/commit/8b430caef41ae550a63a0ac103bf5e136e783cd1?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8d5a6a9`](https://app.codecov.io/gh/apache/superset/commit/8d5a6a99180cd732126ca0e234ed50e2b2aade16?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   :warning: Report is 39 commits behind head on master.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/41334?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [superset/models/helpers.py](https://app.codecov.io/gh/apache/superset/pull/41334?src=pr&el=tree&filepath=superset%2Fmodels%2Fhelpers.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbW9kZWxzL2hlbHBlcnMucHk=) | 11.11% | [16 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/41334?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   > :exclamation:  There is a different number of reports uploaded between BASE (8b430ca) and HEAD (8d5a6a9). Click for more details.
   > 
   > <details><summary>HEAD has 5 uploads less than BASE</summary>
   >
   >| Flag | BASE (8b430ca) | HEAD (8d5a6a9) |
   >|------|------|------|
   >|python|6|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@            Coverage Diff             @@
   ##           master   #41334      +/-   ##
   ==========================================
   - Coverage   64.36%   55.58%   -8.78%     
   ==========================================
     Files        2653     2653              
     Lines      144867   145042     +175     
     Branches    33421    33462      +41     
   ==========================================
   - Hits        93245    80624   -12621     
   - Misses      49949    63682   +13733     
   + Partials     1673      736     -937     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hive](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [mysql](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [postgres](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [presto](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.85% <30.43%> (-0.07%)` | :arrow_down: |
   | [python](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `40.85% <30.43%> (-18.72%)` | :arrow_down: |
   | [sqlite](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unit](https://app.codecov.io/gh/apache/superset/pull/41334/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/superset/pull/41334?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org