Skip to content

fix(table-chart): support where for adhoc columns with server-side pagination#38716

Open
MallikarjunaReddyN wants to merge 3 commits intoapache:masterfrom
MallikarjunaReddyN:fix/support-adhoc-columns-in-table-chart-filter
Open

fix(table-chart): support where for adhoc columns with server-side pagination#38716
MallikarjunaReddyN wants to merge 3 commits intoapache:masterfrom
MallikarjunaReddyN:fix/support-adhoc-columns-in-table-chart-filter

Conversation

@MallikarjunaReddyN
Copy link
Copy Markdown

@MallikarjunaReddyN MallikarjunaReddyN commented Mar 18, 2026

User description

SUMMARY

When using server-side pagination in table charts, filter by custom SQL expression columns (adhoc columns) returns all records.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
table-search-issue.webm

After:
table-search-fix.webm

TESTING INSTRUCTIONS

  • Create Table chart
  • Enable server pagination & Search box
  • Edit the label for column in Dimension section.
  • Choose the edited/renamed label/column in Search by dropdown
  • Enter the value in search box

ADDITIONAL INFORMATION


CodeAnt-AI Description

Allow table chart filters to work with renamed ad hoc columns

What Changed

  • Filters in table charts now work when users pick a custom SQL column by its displayed label, instead of failing or returning all rows
  • Sorting and filtering keep using the underlying column expression for ad hoc columns
  • Added coverage for matching, missing, empty, and multiple ad hoc column cases

Impact

✅ Working table chart filters with renamed columns
✅ Fewer failed searches in server-side pagination
✅ Clearer results when filtering custom SQL columns

💡 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.

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Mar 18, 2026

Code Review Agent Run #13397c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: b70a788..b70a788
    • superset/models/helpers.py
    • tests/unit_tests/models/helpers_test.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

@codeant-ai-for-open-source codeant-ai-for-open-source bot added the size:L This PR changes 100-499 lines, ignoring generated files label Mar 18, 2026
@codeant-ai-for-open-source
Copy link
Copy Markdown
Contributor

Sequence Diagram

This PR updates table query building so search and sorting references that use adhoc column labels are resolved to their SQL expressions. It ensures server side paginated table requests apply WHERE logic correctly for renamed or custom SQL columns.

sequenceDiagram
    participant User
    participant TableAPI
    participant QueryBuilder
    participant Database

    User->>TableAPI: Request paginated table data with search by custom label
    TableAPI->>QueryBuilder: Build query from columns filters and sort
    QueryBuilder->>QueryBuilder: Resolve adhoc label to SQL expression
    QueryBuilder->>Database: Execute paginated query with resolved where and order
    Database-->>QueryBuilder: Return filtered result page
    QueryBuilder-->>User: Return paginated filtered table rows
Loading

Generated by CodeAnt AI

@dosubot dosubot bot added change:backend Requires changing the backend viz:charts:table Related to the Table chart labels Mar 18, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 18, 2026

Codecov Report

❌ Patch coverage is 8.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.32%. Comparing base (834d2ab) to head (b70a788).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
superset/models/helpers.py 8.33% 10 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #38716      +/-   ##
==========================================
- Coverage   65.12%   64.32%   -0.81%     
==========================================
  Files        1819     2532     +713     
  Lines       72690   129738   +57048     
  Branches    23235    29997    +6762     
==========================================
+ Hits        47339    83448   +36109     
- Misses      25351    44837   +19486     
- Partials        0     1453    +1453     
Flag Coverage Δ
hive 40.58% <8.33%> (?)
mysql 61.59% <8.33%> (?)
postgres 61.65% <8.33%> (?)
presto 40.60% <8.33%> (?)
python 63.27% <8.33%> (?)
sqlite 61.29% <8.33%> (?)
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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes server-side pagination table-chart search/sort when users filter/order by renamed adhoc (SQL expression) columns, by resolving label-based references back to their underlying SQL expressions in get_sqla_query.

Changes:

  • Add find_adhoc_column_and_convert_to_sqla() helper to resolve adhoc columns by label to SQLAlchemy expressions.
  • Use the helper to support label-based adhoc references in both ORDER BY and filter (WHERE) handling.
  • Add unit tests covering adhoc label lookup and filter behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
superset/models/helpers.py Introduces a helper and wires it into query generation so filters/orderby can resolve adhoc columns by label.
tests/unit_tests/models/helpers_test.py Adds unit tests for filtering and helper lookup behavior with adhoc column labels.

You can also share your feedback on Copilot code review. Take the survey.

@codeant-ai-for-open-source codeant-ai-for-open-source bot added size:L This PR changes 100-499 lines, ignoring generated files and removed size:L This PR changes 100-499 lines, ignoring generated files labels Mar 24, 2026
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 24, 2026

Deploy Preview for superset-docs-preview ready!

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

QR Code

Use your smartphone camera to open QR code link.

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

@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review bot commented Mar 24, 2026

Code Review Agent Run #4a35ce

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: b70a788..e2b4449
    • superset/models/helpers.py
    • tests/unit_tests/models/helpers_test.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

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 size:L This PR changes 100-499 lines, ignoring generated files viz:charts:table Related to the Table chart

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search is not working after editing/renaming the label/column in Table chart

2 participants