Skip to content

fix(mcp): Skip misleading trend analysis for categorical ASCII charts#39761

Merged
alexandrusoare merged 3 commits into
masterfrom
alexandrusoare/fix/mcp_skip_categorical_charts
May 20, 2026
Merged

fix(mcp): Skip misleading trend analysis for categorical ASCII charts#39761
alexandrusoare merged 3 commits into
masterfrom
alexandrusoare/fix/mcp_skip_categorical_charts

Conversation

@alexandrusoare
Copy link
Copy Markdown
Contributor

SUMMARY

Problem

When an LLM asks for an ASCII chart preview of categorical data (e.g., countries sorted alphabetically), the trend analysis compares first vs last data points and reports statements like "Strong downward trend." This is meaningless — the ordering is alphabetical, not temporal — and misleads LLMs into drawing incorrect conclusions about the data.

Root Cause

_analyze_trend() unconditionally compares values[0] vs values[-1] to determine directional trend, assuming the data is temporally ordered. It has no awareness of whether the x-axis represents time or categories. _extract_time_series_data() already distinguishes date columns from categorical ones (via keyword matching on column names), but this signal was discarded — never propagated to the trend analysis.

Fix

  • _extract_time_series_data now returns an is_temporal flag (True when the label column name contains date/time keywords)
  • _analyze_trend accepts this flag and replaces directional trend statements with a categorical caveat when is_temporal=False
  • Range and volatility stats are preserved regardless — they remain valid for any data

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Apr 29, 2026

Code Review Agent Run #0b9429

Actionable Suggestions - 0
Additional Suggestions
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

Review Details
  • Files reviewed - 2 · Commit Range: ebb9801..ebb9801
    • superset/mcp_service/chart/ascii_charts.py
    • tests/unit_tests/mcp_service/chart/test_ascii_charts.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the change:backend Requires changing the backend label Apr 29, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 29, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit ebb9801
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69f1fa0ccf5e9d00084c88e6
😎 Deploy Preview https://deploy-preview-39761--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 8.33333% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.86%. Comparing base (0a3a350) to head (30e063e).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
superset/mcp_service/chart/ascii_charts.py 8.33% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #39761      +/-   ##
==========================================
- Coverage   64.16%   63.86%   -0.30%     
==========================================
  Files        2591     2585       -6     
  Lines      138302   136940    -1362     
  Branches    32084    31522     -562     
==========================================
- Hits        88736    87457    -1279     
+ Misses      48036    47953      -83     
  Partials     1530     1530              
Flag Coverage Δ
hive 39.41% <8.33%> (-0.03%) ⬇️
mysql 59.08% <8.33%> (-0.05%) ⬇️
postgres 59.16% <8.33%> (-0.05%) ⬇️
presto 41.10% <8.33%> (-0.03%) ⬇️
python 60.59% <8.33%> (-0.05%) ⬇️
sqlite 58.79% <8.33%> (-0.05%) ⬇️
unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@alexandrusoare alexandrusoare merged commit fb276b0 into master May 20, 2026
65 checks passed
@alexandrusoare alexandrusoare deleted the alexandrusoare/fix/mcp_skip_categorical_charts branch May 20, 2026 15:04
@bito-code-review
Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

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

Labels

change:backend Requires changing the backend size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants