Skip to content

fix: Do no aggregate results for CSV downloads from AG Grid raw records table#36247

Merged
Vitor-Avila merged 4 commits into
masterfrom
fix/keep-metrics-as-undefined-for-ag-grid-raw-records
Dec 1, 2025
Merged

fix: Do no aggregate results for CSV downloads from AG Grid raw records table#36247
Vitor-Avila merged 4 commits into
masterfrom
fix/keep-metrics-as-undefined-for-ag-grid-raw-records

Conversation

@Vitor-Avila
Copy link
Copy Markdown
Contributor

@Vitor-Avila Vitor-Avila commented Nov 25, 2025

SUMMARY

The AG Grid un-aggregated table is sending metrics=[] to the backend when a CSV download is triggered from the dashboard, which makes sense (the un-aggregated chart doesn't have any metrics). In the backend, we validate if metrics is not None to decide if a GROUP BY should be added, in this case incorrectly evaluating to True.

As a consequence, the CSV file would only include distinct rows.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before
image

After
image

TESTING INSTRUCTIONS

  1. Create an un-aggregated AG Grid table using the cleaned_sales_data dataset.
  2. Use deal_size as a column.
  3. Save the chart and add it to a dashboard.
  4. Access the dashboard.
  5. Trigger a CSV download.
  6. Validate the CSV includes the same amount of rows returned by the chart.

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 Nov 25, 2025

Code Review Agent Run #3286b4

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: b434be4..b434be4
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.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 Default Agent 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 viz:charts:export Related to exporting charts label Nov 25, 2025
@Vitor-Avila
Copy link
Copy Markdown
Contributor Author

Hey @alexandrusoare it would be good to get your thoughts on this one since you worked on the original PR. Thanks!

Comment thread superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts Outdated
Copy link
Copy Markdown
Contributor

@alexandrusoare alexandrusoare left a comment

Choose a reason for hiding this comment

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

LGTM

@Vitor-Avila Vitor-Avila force-pushed the fix/keep-metrics-as-undefined-for-ag-grid-raw-records branch from b434be4 to 87820c2 Compare November 26, 2025 23:14
@github-actions github-actions Bot removed the plugins label Nov 26, 2025
@Vitor-Avila
Copy link
Copy Markdown
Contributor Author

After talking with @betodealmeida and doing some more testing here, I noticed that this is actually a lot easier to reproduce. Since the AG Grid table is always adding a GROUP BY, downloading an un-aggregated table to CSV would only include distinct rows.

We've agreed to actually take a first pass on fixing this at the backend: the backend should be capable of receiving metrics=[] and not add a group by for it.

@Vitor-Avila Vitor-Avila changed the title fix: Keep metrics as undefined when downloading un-aggregated AG Grid to CSV fix: Do no aggregate results when metrics=[] Nov 26, 2025
Copy link
Copy Markdown
Member

@betodealmeida betodealmeida left a comment

Choose a reason for hiding this comment

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

Yeah!

@Vitor-Avila
Copy link
Copy Markdown
Contributor Author

@betodealmeida will have to revert to fixing this at the AG Grid level. Dashboard native filters intentionally set metrics=[] and expect an aggregation. Personally, I think this is confusing (I understand the need to be able to aggregate without any metric, but I would expect something more explicit instead of just metrics=[]), but changing this would be a larger refactor.

We used to have both groupby and columns but it was deprecated and unified in this PR, which makes sense I agree we can call both use-cases as columns. Ideally, instead of using metrics=[] we would rely on something like QueryMode, but I don't think native filters use that. Long-term, I could see native filters having their own dedicated endpoint to avoid the need to comply with the complexity of /api/v1/chart/data but that's also a larger effort.

Copy link
Copy Markdown
Member

@Antonio-RiveroMartnez Antonio-RiveroMartnez left a comment

Choose a reason for hiding this comment

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

lgtm

@Vitor-Avila Vitor-Avila changed the title fix: Do no aggregate results when metrics=[] fix: Do no aggregate results for CSV downloads from AG Grid raw records table Nov 28, 2025
@Vitor-Avila Vitor-Avila merged commit 9fc7a83 into master Dec 1, 2025
65 checks passed
@Vitor-Avila Vitor-Avila deleted the fix/keep-metrics-as-undefined-for-ag-grid-raw-records branch December 1, 2025 15:52
@betodealmeida
Copy link
Copy Markdown
Member

Dashboard native filters intentionally set metrics=[] and expect an aggregation.

Why?? Do they do this because they want distinct values?

@Vitor-Avila
Copy link
Copy Markdown
Contributor Author

Why?? Do they do this because they want distinct values?

Yes, dashboard filters always display distinct values.

TheDanDan pushed a commit to Wengxin04/superset-cscd01project that referenced this pull request Dec 2, 2025
sadpandajoe pushed a commit that referenced this pull request Dec 4, 2025
@dosubot dosubot Bot mentioned this pull request Dec 12, 2025
3 tasks
Facyla pushed a commit to Facyla/superset-contrib that referenced this pull request Dec 16, 2025
sadpandajoe pushed a commit that referenced this pull request Dec 16, 2025
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Jan 17, 2026
aminghadersohi pushed a commit to aminghadersohi/superset that referenced this pull request Jan 24, 2026
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins size/M viz:charts:export Related to exporting charts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants