Repository navigation
Conversation
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Madan015
force-pushed
the
feature/export-filters-separate-csv
branch
from
November 9, 2026 04:53
80f4923 to
305c04c
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #46090 +/- ##
==========================================
- Coverage 65.35% 65.32% -0.04%
==========================================
Files 3083 3084 +1
Lines 211224 211312 +88
Branches 49803 49804 +1
==========================================
- Hits 138054 138034 -20
- Misses 69992 70098 +106
- Partials 3178 3180 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jchong9
force-pushed
the
feature/export-filters-separate-csv
branch
from
November 9, 2026 06:20
f0e0de1 to
850dddd
Compare
jchong9
force-pushed
the
feature/export-filters-separate-csv
branch
from
November 9, 2026 06:43
850dddd to
cca133b
Compare
… exports Backend: adds the filter_metadata request field, builds the filter rows from the query that ran, and returns the data CSV and filters.csv as a ZIP.
Frontend: adds the two CSV choices to the Explore, standalone, dashboard and drill menus, and greys out the separate file when the CSV will stream. Co-authored-by: Jeremy Chong <chong.jeremy@hotmail.com>
add more tests
jchong9
force-pushed
the
feature/export-filters-separate-csv
branch
from
November 10, 2026 02:46
cca133b to
cd3b512
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
First of five PRs for SIP-237 (#45332). It adds an Include filters as a separate file choice to every chart CSV export that the backend builds. Picking it downloads a ZIP containing the usual data CSV and a
filters.csvthat lists the filters applied to the query that produced the data. Without filter metadata keeps the current export exactly as it is.Request field:
ChartDataQueryContextSchemagets a top-levelfilter_metadatafield with the valuesnone(the default) andseparate.separateis only accepted withresult_format: csv, so any other format gets a 400 error instead of silently ignoring it. The option is stored onQueryContextand is not part of the cache key.Filter rows are built on the backend: The new
superset/utils/export_metadata.pybuilds the rows in_materialize_full_payload()from the query that actually ran, so the file matches the data:applied_filters, are left out.Last week (2026-10-26 to 2026-11-02). A dashboard time range that replaces a chart's saved range is marked as a dashboard filter. Charts saved with the legacy time column are covered.WHEREandHAVINGclauses get their own rows. They are left out for embedded guests who are not allowed to view the query, followingredact_sensitive_query_fields().escape_value()formula protection, and line breaks become spaces.filters.csvuses theCSV_EXPORTencoding and separator, so it matches the data file. The defaultutf-8-sigencoding keeps Excel displaying non-ASCII text correctly.The file: It starts with an "Exported from" line naming the chart and an "Exported at" line with the UTC time. These are followed by the columns Filter, Condition, Value and Source, where Source is Chart filter, Dashboard filter or Custom SQL. If no filters applied, the file says "No filters were applied". A chart with several queries puts
query_1.csv,query_2.csvand so on in the ZIP, with onefilters.csvwhose duplicate rows are removed.Streaming: A CSV that streams cannot be packed into a ZIP. When the frontend knows a CSV will stream (
CSV_STREAMING_ROW_THRESHOLD), the separate file choice is greyed out with a tooltip, and "Without filter metadata" still streams as before. Pivoted CSV and the drill views never stream, so they are never greyed out. If the backend would otherwise decide to stream after the query has run, or an API caller sends a largeexpected_rows, the response is still the ZIP, because the data can still be read normally.Menus: The two choices appear under:
All the menus build their items from one shared helper,
src/utils/exportFilterMetadata.tsx. Excel, JSON and Export Current View are unchanged.Docs: The API docs (
docs/static/resources/openapi.json) are regenerated for the new field. No page indocs/describes the chart export menus, so there is no user guide to update.Drill export names: Drill to detail and Drill by exports previously sent no chart name, so their files were named after the chart type (
superset_echarts_timeseries_bar_…). They now send the drilled chart's name with a prefix, for exampleDrill to detail: Genders by StateorDrill by: Genders by State. That name is used for both the downloaded file (superset_Drill_to_detail_Genders_by_State_…) and the "Exported from" line.Later PRs in this series, not included here:
Notes for reviewers:
get_time_filter_status()marks the range as applied whenever the dataset has a date column.filters.csvonly lists a time range the query actually filtered on.filters.csvlists a dashboard filter under the column it filters, using the dataset's display name, with "Dashboard filter" as its Source. It does not show the name the filter was given on the dashboard.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before: Explore's Export All Data → CSV downloads straight away.

After: CSV opens the two choices.

After: the separate file choice greyed out for a CSV that will stream.

After: a dashboard chart's Download menu.

After: the ZIP's contents, and

filters.csvopened in Excel.TESTING INSTRUCTIONS
Automated tests
pytest tests/unit_tests/utils/test_export_metadata.py tests/unit_tests/charts/test_chart_data_api.py tests/unit_tests/charts/test_schemas.py tests/unit_tests/common/test_query_actions.pysuperset-frontend:npm run test -- src/utils/exportFilterMetadata src/explore src/dashboard/components/SliceHeaderControls src/dashboard/components/gridComponents/Chart src/components/Chart/DrillDetail src/components/Chart/DrillByExplore
birth_namesin aggregate mode, grouped bynamewith the metricSUM(num), and add these filters:genderequalsboystatenot equal toQuébecnamenot equal to=1+1num_boys≥100ds: a custom range, for example 2000-01-01 to 2005-01-01. The sample data covers 1965–2008, so relative ranges such as "Last week" return no rows.WHERE, written over two lines:HAVING:SUM(num) > 500filters.csv. Openfilters.csvin Excel and check that it lists:gender/ equals /boy/ Chart filterstate/ does not equal /Québec, withQuébecdisplayed correctlyname/ does not equal /'=1+1, which stays as text rather than becoming a formulanum_boys/ is greater than or equal to /100ds/ is within / the range followed by its resolved dates(name LIKE 'J%' OR state = 'Québec'), on one line. The line break becomes a space, so there may be extra spaces where it was.(SUM(num) > 500)Other menus
/explore/?slice_id=<id>&standalone=1&show_download=true.Drill by: Genders by State, and the file name should match, for examplesuperset_Drill_by_Genders_by_State_….Grey-out and full CSV
CSV_STREAMING_ROW_THRESHOLD = 100and turn on theALLOW_FULL_CSV_EXPORTfeature flag, which adds the dashboard's Export to full .CSV item for table charts. Then restart.API
POST /api/v1/chart/datawith"filter_metadata": "separate"and"result_format": "xlsx"should return a 400 error.ADDITIONAL INFORMATION