Skip to content

feat(ag-grid): Server Side Filtering for Column Level Filters#35683

Merged
amaannawab923 merged 31 commits into
apache:masterfrom
amaannawab923:ag-grid-server-filters
Jan 12, 2026
Merged

feat(ag-grid): Server Side Filtering for Column Level Filters#35683
amaannawab923 merged 31 commits into
apache:masterfrom
amaannawab923:ag-grid-server-filters

Conversation

@amaannawab923
Copy link
Copy Markdown
Contributor

@amaannawab923 amaannawab923 commented Oct 16, 2025

User description

FEATURE_AG_GRID_TABLE_ENABLED=true

SUMMARY

This PR adds server-side filtering for AG Grid Table V2, allowing users to filter large datasets efficiently directly from column headers.

What it does:
Currently, when server pagination is enabled, AG Grid column filters only work on the current page's data (e.g., filtering 50 rows instead of the full 100,000 rows in the
database). This PR changes that by converting AG Grid filter conditions into SQL queries that execute on the backend.

Key Points:

  • Column filters now work across the entire dataset, not just the current page
  • Supports all common filter types: text (contains, equals, starts with), numbers (greater than, less than, ranges), dates, and blank/not blank checks
  • Handles complex conditions with AND/OR logic (e.g., "state equals CA OR NY")
  • Automatically separates dimension filters (→ WHERE clause) from metric filters (→ HAVING clause) for optimal SQL performance
  • Works in Parity with the Permalink feature and doesn't break Chart State
  • UX enhancement: filter popover auto-reopens after server refresh so users don't lose their place

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

CodeAnt-AI Description

Server-side column filtering for AG Grid table with metric/dimension separation and robust date handling

What Changed

  • Column header filters run on the server for server-pagination tables so filters apply to the entire dataset (not just the current page) and support text, number, date, set, boolean, and blank/not-blank conditions.
  • Filters on metric columns are moved to HAVING clauses while dimension filters go to WHERE (so metric and dimension filters are applied in the correct SQL context).
  • Date filters produce full-day ranges and temporal-range expressions so date comparisons behave as users expect (equals → entire day range, inRange → start/end of days).
  • Complex AND/OR and multi-condition filters are converted into combined SQL WHERE/HAVING expressions; set filters become IN clauses.
  • Filter inputs sync immediately to chart state and ownState, reset pagination to the first page when filtering, and avoid applying AG Grid WHERE filters to the totals query so totals remain correct.
  • Improved filter UX: the code detects which filter input is active (first/second) so popovers and focus can be preserved, and client-side date filter predicates are no-ops when server-side filtering is used.
  • Validation and escaping added for column names and values to prevent injection; invalid or overly long column names are ignored.
  • Extensive unit tests added for filter conversion, initial filter state selection, and filter state management.

Impact

✅ Filters apply to full dataset (not just current page)
✅ Accurate totals unaffected by column-level filters
✅ Clearer date filter behavior and consistent metric/dimension filtering

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

@korbit-ai
Copy link
Copy Markdown

korbit-ai Bot commented Oct 16, 2025

Based on your review schedule, I'll hold off on reviewing this PR until it's marked as ready for review. If you'd like me to take a look now, comment /korbit-review.

Your admin can change your review schedule in the Korbit Console

@bito-code-review
Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped - Draft PR

Bito didn't auto-review because this pull request is in draft status.
No action is needed if you didn't intend for the agent to review it. Otherwise, to manually trigger a review, type /review in a comment and save.
You can change draft PR review settings here, or contact your Bito workspace admin at evan@preset.io.

@amaannawab923 amaannawab923 marked this pull request as ready for review October 20, 2025 12:58
@dosubot dosubot Bot added the change:frontend Requires changing the frontend label Oct 20, 2025
Copy link
Copy Markdown

@korbit-ai korbit-ai Bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Functionality Missing useEffect dependencies ▹ view ✅ Fix detected
Functionality Missing setTimeout cleanup ▹ view ✅ Fix detected
Security SQL injection in set filter IN clause ▹ view ✅ Fix detected
Functionality Unsafe any type for filter value ▹ view ✅ Fix detected
Functionality Unreliable compound filter preservation ▹ view ✅ Fix detected
Functionality Overly broad WHERE clause removal in totals query ▹ view ✅ Fix detected
Functionality Data loss in compound filter preservation ▹ view ✅ Fix detected
Performance Regex recompilation in column validation ▹ view ✅ Fix detected
Performance Inefficient array processing in compound filters ▹ view ✅ Fix detected
Files scanned
File Path Reviewed
superset-frontend/plugins/plugin-chart-ag-grid-table/src/types.ts
superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/components/CustomHeader.tsx
superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTableChart.tsx
superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
superset-frontend/src/components/Chart/ChartRenderer.jsx
superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/useAgGridFilters.ts
superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/index.tsx
superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/agGridFilterConverter.ts

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

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

@LevisNgigi LevisNgigi left a comment

Choose a reason for hiding this comment

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

Looks pretty good, left a few comments, would be great to have more detailed summary/instructions.

Comment thread superset-frontend/plugins/plugin-chart-ag-grid-table/src/types.ts Outdated
Comment thread superset-frontend/plugins/plugin-chart-ag-grid-table/test/tsconfig.json Outdated
@sadpandajoe
Copy link
Copy Markdown
Member

@amaannawab923 can you update the PR description?

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

🎪 Showtime deployed environment on GHA for 245aa0c

Environment: http://18.246.213.254:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Jan 8, 2026

Code Review Agent Run #581a97

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset-frontend/plugins/plugin-chart-ag-grid-table/src/renderers/NumericCellRenderer.tsx - 2
    • Type Safety Improvement · Line 115-115
      Good: Replacing 'any' with SupersetTheme | null improves type safety and aligns with dev standards prohibiting 'any' types.
    • Type Safety Improvement · Line 135-135
      Good: Replacing 'any' with imported ValueRange type enhances type safety.
  • superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts - 1
    • Type annotation added · Line 255-270
      The added type annotation for sortItem aligns with its usage, and moving the colId check earlier avoids unnecessary function calls without changing behavior.
Review Details
  • Files reviewed - 20 · Commit Range: b1ff00d..245aa0c
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/components/CustomHeader.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/index.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTableChart.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/consts.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/renderers/NumericCellRenderer.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/stateConversion.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/types.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/agGridFilterConverter.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/filterStateManager.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/getInitialFilterModel.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/useColDefs.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/utils/agGridFilterConverter.test.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/utils/filterStateManager.test.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/utils/getInitialFilterModel.test.ts
    • superset-frontend/src/components/Chart/ChartRenderer.jsx
    • superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx
    • superset/models/helpers.py
    • superset/utils/core.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • Eslint (Linter) - ✔︎ 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

Comment thread superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts Outdated
Comment thread superset-frontend/plugins/plugin-chart-ag-grid-table/src/stateConversion.ts Outdated
Comment thread superset-frontend/plugins/plugin-chart-ag-grid-table/src/stateConversion.ts Outdated
@kgabryje
Copy link
Copy Markdown
Member

kgabryje commented Jan 8, 2026

I'm going to start testenv-up, unfortuantely feature flags are broken in showtime

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

⚠️ DEPRECATED WORKFLOW ⚠️

@kgabryje This workflow is deprecated! Please use the new Superset Showtime system instead:

Processing your ephemeral environment request here. Action: up. More information on how to use or configure ephemeral environments

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

@kgabryje Ephemeral environment spinning up at http://44.243.124.211:8080. Credentials are 'admin'/'admin'. Please allow several minutes for bootstrapping and startup.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

🎪 Showtime is building environment on GHA for f1ebac6

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

🎪 Showtime is building environment on GHA for 32b7783

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

🎪 Showtime deployed environment on GHA for 32b7783

Environment: http://34.220.144.13:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

🎪 Showtime is building environment on GHA for 970be99

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 8, 2026

🎪 Showtime deployed environment on GHA for 970be99

Environment: http://44.255.121.172:8080 (admin/admin)
Lifetime: 48h auto-cleanup
Updates: New commits create fresh environments automatically

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Jan 8, 2026

Code Review Agent Run #467fa8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 20 · Commit Range: 245aa0c..970be99
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/components/CustomHeader.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/index.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTableChart.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/buildQuery.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/consts.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/renderers/NumericCellRenderer.tsx
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/stateConversion.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/types.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/agGridFilterConverter.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/filterStateManager.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/getInitialFilterModel.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/src/utils/useColDefs.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/buildQuery.test.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/utils/agGridFilterConverter.test.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/utils/filterStateManager.test.ts
    • superset-frontend/plugins/plugin-chart-ag-grid-table/test/utils/getInitialFilterModel.test.ts
    • superset-frontend/src/components/Chart/ChartRenderer.jsx
    • superset-frontend/src/explore/components/useExploreAdditionalActionsMenu/index.jsx
    • superset/models/helpers.py
    • superset/utils/core.py
  • 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 evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Copy link
Copy Markdown
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

Did some testing, works very nice!
I didn't test every operator, but did some sanity checks on date, string and numerical filters.
LGTM!

@kgabryje
Copy link
Copy Markdown
Member

2 ideas for future improvements:

  1. Perhaps View query should include the table filters?
  2. Changing a page or setting a filter reloads the whole chart component. It would be a much better user experience if we didn't completely unmount the table, but instead display a loading spinner inside the table

@codeant-ai-for-open-source
Copy link
Copy Markdown
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

@amaannawab923
Copy link
Copy Markdown
Contributor Author

2 ideas for future improvements:

  1. Perhaps View query should include the table filters?
  2. Changing a page or setting a filter reloads the whole chart component. It would be a much better user experience if we didn't completely unmount the table, but instead display a loading spinner inside the table

Thanks for these suggestions, @kgabryje ! Both are great ideas for future improvements.

  1. "View Query" including table filters - Agreed, this would be a valuable addition. We can look into including the applied filter clauses in the query view.

  2. Avoiding full component reload on page/filter changes - This is something i explored but unfortunately couldn't implement in the current PR. The challenge is that the Superset plugin architecture unmounts and re-renders the entire chart component whenever a new API call is triggered. This means the AG Grid instance gets destroyed and recreated on each request, making it difficult to show an in-table loading spinner while preserving the existing table state.

Addressing this would require changes at the Superset plugin/chart rendering level to support partial updates without full unmounts , which is beyond the scope of this PR but definitely worth exploring as a follow-up.

I'll add both of these as candidates for future improvements. Thanks again for the thoughtful feedback!

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

Labels

change:frontend Requires changing the frontend plugins size/XXL size:XXL This PR changes 1000+ lines, ignoring generated files 🎪 ⌛ 48h Environment expires after 48 hours (default)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants