Skip to content

fix(reports): respect CSV_EXPORT sep and decimal config in email reports - #38616

Merged
rusackas merged 1 commit into
apache:masterfrom
nitishagar:fix-36682
Jul 1, 2026
Merged

rusackas merged 1 commit into
apache:masterfrom
nitishagar:fix-36682

Conversation

@nitishagar

@nitishagar nitishagar commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

User description

SUMMARY

When CSV_EXPORT config uses a non-default delimiter (e.g. sep=";") and decimal separator (e.g. decimal=","), GUI CSV exports work correctly because they go through query_context_processor.py which passes **current_app.config["CSV_EXPORT"] to df_to_escaped_csv(). However, CSV email reports take a different path through apply_client_processing() in client_processing.py, which called pd.read_csv(StringIO(data)) without reading sep/decimal from the config.

This caused pandas to misparse the semicolon-delimited CSV (treating the whole row as one column), which then broke the pivot/table post-processor and returned an HTTP 500.

Fix: Read sep and decimal from current_app.config["CSV_EXPORT"] and pass them to pd.read_csv(), defaulting to "," and "." respectively when not configured.

Fixes #36682

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend-only fix.

TESTING INSTRUCTIONS

  1. Configure CSV_EXPORT = {"sep": ";", "decimal": ","} in superset_config.py
  2. Create a chart and schedule a CSV email report
  3. Before fix: report fails with HTTP 500 (pandas misparsed the semicolon-delimited data)
  4. After fix: report processes correctly and sends valid CSV email

Unit test added:

pytest tests/unit_tests/charts/test_client_processing.py::test_apply_client_processing_csv_format_custom_delimiter -v

ADDITIONAL INFORMATION


CodeAnt-AI Description

Respect CSV export settings in scheduled reports

What Changed

  • Scheduled CSV email reports now use the same delimiter and decimal settings as regular CSV exports, so semicolon-separated files are read and written correctly.
  • Reports no longer fail when CSV data uses custom separators or decimal marks; table and pivot reports continue processing the data normally.
  • Existing missing-value handling still works alongside the CSV export settings.

Impact

✅ Fewer failed CSV email reports
✅ Correct parsing for semicolon-delimited exports
✅ Clearer scheduled report output with custom decimal formats

💡 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

bito-code-review Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #c83433

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 3db389b..3db389b
    • superset/charts/client_processing.py
    • tests/unit_tests/charts/test_client_processing.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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the data:csv Related to import/export of CSVs label Mar 13, 2026
@codeant-ai-for-open-source codeant-ai-for-open-source Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Mar 13, 2026
Comment on lines +2827 to +2832
output_data = processed_result["queries"][0]["data"]
lines = output_data.strip().split("\n")
# Should have header + 2 data rows, with correct column parsing
assert len(lines) == 3
# name and value should be separate columns, not merged into one
assert processed_result["queries"][0]["colnames"] == ["name", "value"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggestion: This test does not actually verify that the configured delimiter/decimal are preserved in the generated CSV output, so it can pass even when email CSV exports are still emitted with default comma and dot formatting. Strengthen the assertions to validate the serialized CSV content and numeric typing of the parsed value column. [logic error]

Severity Level: Major ⚠️
- ❌ Scheduled CSV emails may ignore configured separator/decimal output.
- ⚠️ Current unit test misses CSV serialization regressions.
Suggested change
output_data = processed_result["queries"][0]["data"]
lines = output_data.strip().split("\n")
# Should have header + 2 data rows, with correct column parsing
assert len(lines) == 3
# name and value should be separate columns, not merged into one
assert processed_result["queries"][0]["colnames"] == ["name", "value"]
output_data = processed_result["queries"][0]["data"]
lines = output_data.strip().split("\n")
# Should have header + 2 data rows, with correct column parsing
assert len(lines) == 3
# name and value should be separate columns, not merged into one
assert processed_result["queries"][0]["colnames"] == ["name", "value"]
# value should be parsed as numeric using decimal="," config
assert processed_result["queries"][0]["coltypes"] == [
GenericDataType.STRING,
GenericDataType.NUMERIC,
]
# serialized CSV should honor configured separator/decimal for email exports
assert lines[0] == "name;value"
assert "foo;1,5" in lines[1]
assert "bar;2,0" in lines[2]
Steps of Reproduction ✅
1. Configure a report with non-default CSV settings
(`CSV_EXPORT={"sep":";","decimal":","}`), then trigger scheduled CSV generation through
`ReportScheduleStateMachine._get_csv_data()` in
`superset/commands/report/execute.py:439-443`, which calls `ChartDataRestApi.get_data`
with `type=post_processed` at `execute.py:226-230`.

2. In chart response handling, `_send_chart_response()` applies post-processing when
`result_type == POST_PROCESSED` (`superset/charts/data/api.py:404-405`), invoking
`apply_client_processing()`.

3. In `apply_client_processing()`, CSV is parsed with configured `sep`/`decimal`
(`superset/charts/client_processing.py:348-356`) but serialized back using default
`processed_df.to_csv(...)` without config (`client_processing.py:397`), yielding comma/dot
formatted output.

4. Run the current unit test `test_apply_client_processing_csv_format_custom_delimiter`
(`tests/unit_tests/charts/test_client_processing.py:2794-2832`): it only asserts row count
and `colnames` (`2827-2832`), so it still passes even when output CSV formatting is wrong.
Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** tests/unit_tests/charts/test_client_processing.py
**Line:** 2827:2832
**Comment:**
	*Logic Error: This test does not actually verify that the configured delimiter/decimal are preserved in the generated CSV output, so it can pass even when email CSV exports are still emitted with default comma and dot formatting. Strengthen the assertions to validate the serialized CSV content and numeric typing of the parsed `value` column.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
👍 | 👎

@codecov

codecov Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.41%. Comparing base (ce9b9b0) to head (52aafad).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
superset/charts/client_processing.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #38616      +/-   ##
==========================================
- Coverage   64.42%   64.41%   -0.01%     
==========================================
  Files        2668     2668              
  Lines      147182   147185       +3     
  Branches    33947    33947              
==========================================
- Hits        94821    94816       -5     
- Misses      50646    50652       +6     
- Partials     1715     1717       +2     
Flag Coverage Δ
hive 39.10% <0.00%> (-0.01%) ⬇️
mysql 57.65% <0.00%> (-0.01%) ⬇️
postgres 57.71% <0.00%> (-0.01%) ⬇️
presto 40.65% <0.00%> (-0.01%) ⬇️
python 59.12% <0.00%> (-0.01%) ⬇️
sqlite 57.35% <0.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.

nitishagar added a commit to nitishagar/superset that referenced this pull request Mar 13, 2026
…d CSV output

The previous fix only passed sep and decimal to pd.read_csv() (parsing the
input CSV), but to_csv() was still called with pandas defaults, so email report
attachments were still serialized with ',' and '.' regardless of config.

Pass the same sep and decimal values to to_csv() so the round-trip is complete:
configured separator and decimal are preserved in the output CSV sent as email
attachment.

Also strengthen the test to assert that the output CSV uses the configured
separator and decimal, not just that column names were parsed correctly.

Addresses review feedback on apache#38616.
@bito-code-review

bito-code-review Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #f1c406

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 6492ffa..b162f2b
    • superset/charts/client_processing.py
    • tests/unit_tests/charts/test_client_processing.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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes scheduled CSV email report processing to respect CSV_EXPORT delimiter/decimal settings so pandas parses non-comma CSV correctly and avoids post-processing errors.

Changes:

  • Pass configured sep/decimal to pd.read_csv() when processing CSV results in apply_client_processing.
  • Emit processed CSV using the same sep/decimal via DataFrame.to_csv().
  • Add a unit test covering semicolon-delimited CSV with comma decimals.

Reviewed changes

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

File Description
superset/charts/client_processing.py Reads CSV_EXPORT config and applies sep/decimal consistently for CSV read/write in report processing.
tests/unit_tests/charts/test_client_processing.py Adds a regression test for custom delimiter/decimal behavior in apply_client_processing.

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

processed_result = apply_client_processing(result, form_data)

output_data = processed_result["queries"][0]["data"]
lines = output_data.strip().split("\n")
Comment thread superset/charts/client_processing.py Resolved
Comment thread superset/charts/client_processing.py Resolved
@sadpandajoe

Copy link
Copy Markdown
Member

Up to you do to do this or not, but I would consider adding a test for pivot_table_v2. Pivot table does a lof of DataFrame manipulation and the to_csv(decimal=decimal) culd behave differently.

@sadpandajoe

Copy link
Copy Markdown
Member

Additional tests to consider:

  • We should look at a test to make sure na_values and sep/decimal works together.
  • Test partial config where you might get decimal but won't get sep

@sadpandajoe sadpandajoe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some suggestions but none are blockers, so going to approve.

@pull-request-size pull-request-size Bot added size/L and removed size/M labels Mar 24, 2026
@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:M This PR changes 30-99 lines, ignoring generated files labels Mar 24, 2026
@bito-code-review

bito-code-review Bot commented Mar 24, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #802f2f

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: fccc6c3..fccc6c3
    • superset/charts/client_processing.py
    • tests/unit_tests/charts/test_client_processing.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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@mistercrunch mistercrunch left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM outside of CI errors, needs pre-commit/ruff to run

@rusackas

Copy link
Copy Markdown
Member

@nitishagar this is in good shape and the fix seems right, but it's gone stale: it's now conflicting with master and pre-commit is failing. Can you rebase and run pre-commit run --all-files to clear the ruff failure? Once CI's green we'll re-review.

@rusackas

Copy link
Copy Markdown
Member

I'll see if I can help CI along here...

@rusackas

Copy link
Copy Markdown
Member

The rebase proved non-trivial... the PR's read-side CSV sep/decimal fix is good for prod, but master rewrote the write side and added #32371's tests that FAIL with the PR applied. Resolving means making a data-format-model call and rewriting master's two new tests to feed config-formatted input. Feel free to take a look at this, if you'd like, or perhaps I can find time to make more significant edits if you'd like.

@rusackas rusackas added the merge-if-green If approved and tests are green, please go ahead and merge it for me label Jul 1, 2026
@bito-code-review

bito-code-review Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #376f8a

Actionable Suggestions - 0
Additional Suggestions - 3
  • superset/charts/client_processing.py - 1
    • Dead code in JSON path · Line 342-344
      The `sep` and `decimal` config lookups are executed for every query iteration but are only consumed when `result_format == CSV`. Moving these lines inside the CSV branch (after line 348) eliminates unnecessary config lookups and config dictionary iteration for JSON-format queries.
  • tests/unit_tests/charts/test_client_processing.py - 2
    • Missing return type annotation · Line 2840-2840
      Add explicit `-> None` return type annotation. BITO.md rule 7819 requires return type hints on all functions, including test methods, for consistency and static type checking.
    • Missing return type annotation · Line 2886-2886
      Add explicit `-> None` return type annotation. BITO.md rule 7819 requires return type hints on all functions, including test methods, for consistency and static type checking.
Review Details
  • Files reviewed - 2 · Commit Range: 52aafad..52aafad
    • superset/charts/client_processing.py
    • tests/unit_tests/charts/test_client_processing.py
  • Files skipped - 0
  • Tools
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ 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 [email protected].

Documentation & Help

AI Code Review powered by Bito Logo

@rusackas
rusackas merged commit 792d677 into apache:master Jul 1, 2026
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data:csv Related to import/export of CSVs merge-if-green If approved and tests are green, please go ahead and merge it for me size/L size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSV email reports fail with HTTP 500 when using non-default CSV delimiter (GUI CSV export works)

5 participants