Skip to content

Conversation

@anumukul
Copy link

@anumukul anumukul commented Jan 6, 2026

SUMMARY

Fixes #36806

This PR fixes a regression where offset metrics (time comparisons like "1 year ago") were not displayed as dashed lines when charts have no dimensions.

Root Cause:
The isDerivedSeries function only applied dashed styling when comparison_type === "Values", and hasTimeOffset didn't detect series where the name exactly matched a time offset (which happens when there are no dimensions).

Changes:

  • Removed the restrictive comparison_type === "Values" check in isDerivedSeries.ts
  • Added exact match handling in timeOffset.ts for dimension-less charts
  • Updated tests to reflect new behavior

BEFORE/AFTER

BEFORE
image

**AFTER **

image

TESTING INSTRUCTIONS

  1. Create a new Line Chart
  2. Select a dataset with a time column (e.g., birth_names with ds)
  3. Add a metric (e.g., COUNT(*))
  4. Set Time Range to a valid range (e.g., 2005-01-01 to 2008-12-31)
  5. In Advanced Analytics, add Time Comparison: 1 year ago
  6. Do NOT add any dimensions (leave Dimensions empty)
  7. Click "Update Chart"
  8. Verify the offset metric line (1 year ago) appears dashed, not solid

ADDITIONAL INFORMATION

…ison_type

This fixes a regression where offset metrics (time comparisons like
'1 year ago') were not displayed as dashed lines when:
- comparison_type was not set to 'Values'
- the chart had no dimensions

Changes:
- Remove comparison_type check in isDerivedSeries.ts
- Add exact match handling in timeOffset.ts for dimension-less charts
- Update tests to reflect new behavior

Fixes apache#36806
@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI is reviewing your PR.


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@netlify
Copy link

netlify bot commented Jan 6, 2026

Deploy Preview for superset-docs-preview canceled.

Name Link
🔨 Latest commit 845701e
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/695cea981190d60008f288ce

@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 6, 2026

Code Review Agent Run #ff9a91

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 845701e..845701e
    • superset-frontend/packages/superset-ui-chart-controls/src/operators/utils/isDerivedSeries.ts
    • superset-frontend/packages/superset-ui-chart-controls/src/operators/utils/timeOffset.ts
    • superset-frontend/packages/superset-ui-chart-controls/test/operators/utils/isDerivedSeries.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot bot added the viz:charts Namespace | Anything related to viz types label Jan 6, 2026
@codeant-ai-for-open-source
Copy link
Contributor

Nitpicks 🔍

🔒 No security issues identified
⚡ Recommended areas for review

  • Behavioral change
    The removed guard that required comparison_type === ComparisonType.Values means any chart with a time_compare entry may now mark series as derived. Verify this doesn't enable dashed styling for other comparison types unintentionally. Confirm desired behavior across all supported comparison_type values.

  • getTimeOffset guard
    The exported helper getTimeOffset assumes series.name is a string (it calls .includes), but it has no internal type guard. While hasTimeOffset now checks the type before calling it, other call sites could call getTimeOffset directly and trigger a runtime error if series.name is undefined or non-string. Consider making getTimeOffset defensive about series.name or narrow its parameter type.

  • Behavior change
    Removing the restriction that only ComparisonType.Values marks a derived series means series whose names match time offsets will now be treated as derived regardless of the configured comparison_type. This can change visual styling (dashed vs solid lines) in other comparison modes; verify this is intended across chart types and UI surface.

  • Matching robustness
    The new exact-match check (timeCompare.includes(series.name)) in hasTimeOffset fixes a regression but can still miss matches due to leading/trailing whitespace or minor formatting differences. Also, logic is split between getTimeOffset (pattern matches) and hasTimeOffset (exact match), which may lead to maintenance churn. Consider centralizing and normalizing comparisons (trim/case) and consolidating matching logic.

  • Viz type clarity
    The shared formData uses VizType.Table. The regression being fixed relates to charts with no dimensions (e.g. line charts); confirm tests reflect the intended chart type or add explicit tests for relevant viz types so behavior for dimension-less charts is validated.

Comment on lines 37 to 40
): boolean =>
typeof series.name === 'string'
? !!getTimeOffset(series, timeCompare)
? !!getTimeOffset(series, timeCompare) || timeCompare.includes(series.name)
: false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Performance bug: calling getTimeOffset (which scans timeCompare) and then calling timeCompare.includes(...) performs two separate linear scans over timeCompare; compute the offset once and reuse the result to avoid the duplicate O(n) work. [performance]

Severity Level: Minor ⚠️

Suggested change
): boolean =>
typeof series.name === 'string'
? !!getTimeOffset(series, timeCompare)
? !!getTimeOffset(series, timeCompare) || timeCompare.includes(series.name)
: false;
): boolean => {
if (typeof series.name !== 'string') return false;
const foundOffset = getTimeOffset(series, timeCompare);
if (foundOffset) return true;
return Array.isArray(timeCompare) && timeCompare.includes(series.name);
};
Why it matters? ⭐

Calling getTimeOffset (which iterates timeCompare) and then timeCompare.includes(...) results in two linear scans. Caching the result of getTimeOffset and reusing it avoids the duplicate O(n) work with no behavioral change, so this is a valid micro-optimization.

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** superset-frontend/packages/superset-ui-chart-controls/src/operators/utils/timeOffset.ts
**Line:** 37:40
**Comment:**
	*Performance: Performance bug: calling `getTimeOffset` (which scans `timeCompare`) and then calling `timeCompare.includes(...)` performs two separate linear scans over `timeCompare`; compute the offset once and reuse the result to avoid the duplicate O(n) work.

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.

@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI finished reviewing your PR.

…ators/utils/isDerivedSeries.ts

Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
@codeant-ai-for-open-source
Copy link
Contributor

CodeAnt AI is running Incremental review


Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

…ators/utils/isDerivedSeries.ts

Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
@bito-code-review
Copy link
Contributor

bito-code-review bot commented Jan 7, 2026

Code Review Agent Run #e4959d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 845701e..94997dd
    • superset-frontend/packages/superset-ui-chart-controls/src/operators/utils/isDerivedSeries.ts
    • superset-frontend/packages/superset-ui-chart-controls/src/operators/utils/timeOffset.ts
    • superset-frontend/packages/superset-ui-chart-controls/test/operators/utils/isDerivedSeries.test.ts
  • Files skipped - 0
  • Tools
    • Eslint (Linter) - ✔︎ Successful
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Copy link
Member

@justinpark justinpark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

packages size/M viz:charts Namespace | Anything related to viz types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offset metrics are not displayed as dashed lines on line chart in version 6.0.0.

2 participants