superset icon indicating copy to clipboard operation
superset copied to clipboard

feat(explore): add interactive table query building with SQL visibility

Open eschutho opened this issue 2 weeks ago • 5 comments

User description

SUMMARY

This PR introduces interactive table capabilities inspired by Omni's data curation approach, where the table becomes a query-building interface rather than just output.

Key Features:

Query Tab in Explore (76c49efb)

Adds a new "Query" tab in the Data panel (alongside Results and Samples) Displays the generated SQL with syntax highlighting Auto-updates when form data changes, providing real-time SQL visibility Column Header Context Menu for Standard Table (a1ea1af1)

Right-click context menu on column headers in the standard Table chart Options: "Group by this column", "Add as metric" (SUM/AVG/COUNT/etc.), "Hide column" Uses setControlValue hook to update Explore controls Column Header Interactions for AG Grid Table (4b2e6d12)

Extends AG Grid's existing kebab menu with the same interactive options Group by, Add as metric (with submenu for aggregates), Hide column Only appears in Explore context (when setControlValue is available) How It Works:

Users can click on column headers to add Group By dimensions or create aggregate metrics The Query tab shows the SQL updating in real-time as users interact with the table This creates a bidirectional workflow: see data → click to refine → see SQL change → repeat

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: Tables are output-only; users must manually configure controls to change the query

After:

Column headers have context menus for quick query modification New Query tab shows the generated SQL that updates as you interact with the table

TESTING INSTRUCTIONS

Navigate to Explore with any dataset Select either "Table" or "AG Grid Table" visualization Run a query with some columns Test Query Tab: 4. Click on the "Query" tab in the data panel (next to Results/Samples) 5. Verify SQL is displayed with syntax highlighting 6. Change a control (e.g., add a metric) and verify SQL updates

Test Column Interactions (Standard Table): 7. Right-click on a dimension column header 8. Click "Group by this column" - verify column is added to Group By control 9. Right-click on a numeric column, hover "Add as metric", select "SUM" 10. Verify a new SUM metric appears in the Metrics control 11. Click "Hide column" and verify the column is hidden

Test Column Interactions (AG Grid Table): 12. Switch to AG Grid Table visualization 13. Click the kebab menu (⋮) on a column header 14. Verify "Group by this column", "Add as metric", and "Hide column" options appear 15. Test each option and verify controls update correctly

ADDITIONAL INFORMATION

  • [ ] Has associated issue:
  • [ ] Required feature flags:
  • [x] Changes UI
  • [ ] Includes DB Migration
  • [x] Introduces new feature or API
  • [ ] Removes existing feature or API

Technical Notes:

Uses setControlValue from chart hooks to update Explore controls from within chart plugins Uses getChartDataRequest with resultType: 'query' to fetch generated SQL Column interactions are only visible in Explore context (not on dashboards)


CodeAnt-AI Description

Show generated SQL and enable column-based query edits from table headers

What Changed

  • Adds a new "Query" tab in the data panel that fetches and displays the generated SQL for the current chart, with syntax highlighting and a Copy button; it loads when the panel is open and the query is run.
  • Adds context-menu interactions on table and AG Grid column headers that let users directly modify the underlying query: "Group by this column", "Add as metric" (SUM/AVG/MIN/MAX/COUNT/COUNT DISTINCT), and "Hide column". Numeric-only aggregates are shown for numeric columns.
  • Column interactions only appear when Explore controls are available and update the chart controls (groupby, metrics, column_config), causing the query to refresh; the metric submenu is shown as a hover submenu.

Impact

✅ Real-time SQL visibility for charts ✅ Shorter query iteration by clicking table columns to add group-bys or metrics ✅ Hide columns from the table without opening the control panel

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

eschutho avatar Dec 20 '25 05:12 eschutho