Skip to content

fix(dashboard): build example-export sample data through the dataset query path#40976

Open
sha174n wants to merge 7 commits into
apache:masterfrom
sha174n:fix/export-example-dataset-query-path
Open

fix(dashboard): build example-export sample data through the dataset query path#40976
sha174n wants to merge 7 commits into
apache:masterfrom
sha174n:fix/export-example-dataset-query-path

Conversation

@sha174n

@sha174n sha174n commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

SUMMARY

The dashboard "export as example" data path (export_dataset_data in superset/commands/dashboard/export_example.py) read dataset rows with a hand-built pd.read_sql(...) straight against the dataset's engine. That skipped the dataset's own query builder, so the exported sample could differ from what the same user gets through the regular chart-data path.

This routes the data export through the dataset's query() method, so the sample is produced the same way as everywhere else:

  • the dataset's access check runs before any rows are read (a dataset the requester cannot access yields no data file);
  • the column projection and the dataset's configured per-row filtering are applied consistently with the chart-data path;
  • the sample cap is applied at the SQL level via row_limit instead of reading the full table and trimming afterward.

The query path reports failures via status rather than raising, so a failed query now omits the data file instead of writing an empty Parquet, matching the previous behavior. No change for an admin/owner exporting datasets they fully control.

TESTING INSTRUCTIONS

pytest tests/unit_tests/commands/dashboard/export_example_test.py
pytest tests/integration_tests/dashboards/api_tests.py -k export_as_example

New unit tests cover the access-denied, query-path, row-limit, and failed-query branches. A new integration test exports a dashboard as a user constrained by a per-row filter on the dataset and asserts the export only contains the rows that filter allows.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

🤖 Generated with Claude Code

sha174n and others added 3 commits June 11, 2026 15:00
The example-export data path now fetches rows through the dataset's own
query builder and applies the dataset access check before reading any
rows, so exported sample data is produced the same way as the chart-data
path (column projection, per-row filters) and reflects the requester's
dataset access. The row cap is applied at the SQL level via row_limit
instead of after a full table read. A requester without access to a
dataset yields no data file rather than the raw underlying table.

Adds unit coverage for the access-denied and query-path branches.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds an end-to-end regression test: a Gamma user restricted by a
row-level filter on birth_names exports the births dashboard and must
only receive the rows the filter allows. Verified to fail against the
pre-change data path (full table leaked) and pass after it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…failure

The dataset query path signals failures via QueryResult.status (returning
an empty frame) rather than raising, so a failed query would have written
an empty Parquet. Treat a FAILED status as no data and omit the file,
matching the prior raise-and-skip behavior. Adds unit coverage for the
failed-query branch and restores the shared test role's permissions after
the row-level-filter integration test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@netlify

netlify Bot commented Jun 11, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 5bb79f7
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a2ae0ab211a7a0008f4a268
😎 Deploy Preview https://deploy-preview-40976--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

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.29%. Comparing base (74845ea) to head (67f493b).

Files with missing lines Patch % Lines
superset/commands/dashboard/export_example.py 50.00% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40976      +/-   ##
==========================================
- Coverage   64.30%   64.29%   -0.01%     
==========================================
  Files        2657     2657              
  Lines      144060   144059       -1     
  Branches    33216    33214       -2     
==========================================
- Hits        92641    92626      -15     
- Misses      49797    49810      +13     
- Partials     1622     1623       +1     
Flag Coverage Δ
hive 39.44% <11.11%> (+<0.01%) ⬆️
mysql 58.19% <50.00%> (+<0.01%) ⬆️
postgres 58.26% <50.00%> (-0.01%) ⬇️
presto 41.04% <11.11%> (+<0.01%) ⬆️
python 59.72% <50.00%> (-0.01%) ⬇️
sqlite 57.88% <50.00%> (+<0.01%) ⬆️
unit 100.00% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@sha174n sha174n marked this pull request as ready for review June 11, 2026 21:36
@dosubot dosubot Bot added dashboard:export Related to exporting dashboards data:dataset Related to dataset configurations labels Jun 11, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread tests/integration_tests/dashboards/api_tests.py Outdated
Comment thread tests/unit_tests/commands/dashboard/export_example_test.py
Comment thread tests/unit_tests/commands/dashboard/export_example_test.py Outdated
Comment thread tests/unit_tests/commands/dashboard/export_example_test.py Outdated
Comment thread tests/unit_tests/commands/dashboard/export_example_test.py Outdated
Comment thread tests/unit_tests/commands/dashboard/export_example_test.py Outdated
@bito-code-review

bito-code-review Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f54a14

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: 81f4885..4bee77c
    • superset/commands/dashboard/export_example.py
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/commands/dashboard/export_example_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

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bito-code-review

bito-code-review Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #823800

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 4bee77c..67f493b
    • tests/integration_tests/dashboards/api_tests.py
    • tests/unit_tests/commands/dashboard/export_example_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

dashboard:export Related to exporting dashboards data:dataset Related to dataset configurations size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant