Skip to content

fix(dataframe): normalize trusted nonfinite scalars - #44219

Merged
rusackas merged 4 commits into
apache:masterfrom
aminghadersohi:sc-119162-mcp-strict-dataframe-json
Sep 29, 2026
Merged

rusackas merged 4 commits into
apache:masterfrom
aminghadersohi:sc-119162-mcp-strict-dataframe-json

Conversation

@aminghadersohi

@aminghadersohi aminghadersohi commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

SUMMARY

Extracts self-contained DataFrame/JSON scalar normalization from #43771 so that the Sunburst feature PR has a smaller, more reviewable scope.

The projection boundary now normalizes exact trusted pandas, Python float, NumPy float, and Decimal missing/non-finite scalars to None without invoking equality or numeric hooks on arbitrary object-column values. Query-context output, synchronous SQL Lab output, and asynchronous SQL result serialization therefore emit strict JSON nulls rather than NaN/Infinity tokens while preserving finite Decimal precision. JavaScript-unsafe integers are stringified at the query-context producer boundary, and finite np.longdouble values are classified without narrowing through Python float.

This change is independent of Sunburst and can land before #43771. The other independent extraction is #44218. Once merged, #43771 can absorb master normally and its corresponding diff disappears without rewriting either branch.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable; backend serialization behavior only.

TESTING INSTRUCTIONS

PYTHONPATH="$PWD/superset-core/src:$PYTHONPATH" pytest -q \
  tests/unit_tests/dataframe_test.py \
  tests/unit_tests/common/test_query_context_processor.py \
  tests/unit_tests/sql/execution/test_celery_task.py \
  tests/unit_tests/sql_lab_test.py
# 152 passed

pre-commit run
# Passed for all staged files.

Regression coverage includes finite/non-finite Decimal and np.longdouble values, browser-safe integer wire serialization, NumPy/pandas missing values, hostile object equality/numeric hooks, synchronous SQL Lab serialization, and asynchronous SQL result serialization.

Exact-head CI: ee59e685f8adfc53485d07c6d3c62b66739bbdcd is mergeable. Focused tests and pre-commit pass; integration checks are blocked by the two migration heads present on the current master merge result (c7f53d184ea2 and 88a01c781622).

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Comment thread superset/dataframe.py Resolved
@codecov

codecov Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.22%. Comparing base (b6be1dd) to head (fdbd342).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #44219   +/-   ##
=======================================
  Coverage   81.21%   81.22%           
=======================================
  Files        2968     2968           
  Lines      179363   179417   +54     
  Branches    41597    41606    +9     
=======================================
+ Hits       145675   145733   +58     
+ Misses      30977    30975    -2     
+ Partials     2711     2709    -2     
Flag Coverage Δ
hive 36.73% <53.33%> (-0.01%) ⬇️
mysql 56.06% <70.00%> (-0.01%) ⬇️
postgres 56.06% <70.00%> (-0.01%) ⬇️
presto 38.62% <56.66%> (-0.02%) ⬇️
python 85.49% <100.00%> (+0.01%) ⬆️
sqlite 55.78% <63.33%> (-0.01%) ⬇️
unit 77.80% <100.00%> (+0.02%) ⬆️

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.

@bito-code-review bito-code-review Bot 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.

Code Review Agent Run #c713d3

Actionable Suggestions - 1
  • superset/dataframe.py - 1
Additional Suggestions - 2
  • tests/unit_tests/sql_lab_test.py - 1
    • Tautological test assertion · Line 94-96
      This assertion always passes: in the non-msgpack branch `_deserialize_results_payload` (views/utils.py:668) just calls `json.loads(payload)` from the same `superset.utils.json` module as `superset_json.loads`, so both sides are identical. It verifies nothing about the view consumer's projection. Assert the actual deserialized `data` values (None for non-finite, `float(finite)` for the finite Decimal) instead.
  • tests/unit_tests/dataframe_test.py - 1
    • Misleading JSON assertion · Line 96-96
      `superset_json.dumps` serializes the finite `Decimal` through `float()` in `base_json_conv`, so the emitted JSON number is `0.1`, not `0.10000000000000000001`. This assertion only passes because Python collapses `0.10000000000000000001 == 0.1`, masking that Decimal precision is lost on serialization. Assert `0.1` to reflect real behavior.
Review Details
  • Files reviewed - 6 · Commit Range: 6d141c1..6d141c1
    • superset/common/query_context_processor.py
    • superset/dataframe.py
    • tests/unit_tests/common/test_query_context_processor.py
    • tests/unit_tests/dataframe_test.py
    • tests/unit_tests/sql/execution/test_celery_task.py
    • tests/unit_tests/sql_lab_test.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 an incremental AI Review.

  • /review full - 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

Comment thread superset/dataframe.py Resolved
@netlify

netlify Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

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

@bito-code-review

bito-code-review Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #fce4dc

Actionable Suggestions - 0
Additional Suggestions - 2
  • tests/unit_tests/dataframe_test.py - 1
    • Platform-dependent test value · Line 50-50
      `np.longdouble("1e400")` is only finite where longdouble has extended precision (x86-64 Linux/macOS). On Windows (MSVC, no x87 long double) and aarch64, `np.longdouble` is a 64-bit double, so `1e400` overflows to `inf` and `records[0]["value"]` becomes `None`, failing the `is finite` assertion. Use `np.finfo(np.longdouble).max` for a portable finite value.
  • tests/unit_tests/common/test_query_context_processor.py - 1
    • Platform-dependent test value · Line 202-202
      `np.longdouble("1e400")` is finite only where long double has 80-bit extended precision (Linux x86-64). On Windows (MSVC) and Apple Silicon (ARM64) long double is 64-bit, so 1e400 overflows to `inf` and `assert result[0]["longdouble"] is finite_longdouble` fails. Use `np.longdouble("1e300")`, finite on all platforms, to keep the test portable.
Review Details
  • Files reviewed - 4 · Commit Range: 6d141c1..ee59e68
    • superset/common/query_context_processor.py
    • superset/dataframe.py
    • tests/unit_tests/common/test_query_context_processor.py
    • tests/unit_tests/dataframe_test.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 an incremental AI Review.

  • /review full - 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

@bito-code-review

bito-code-review Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #8cae59

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: ee59e68..fdbd342
    • superset/dataframe.py
    • tests/unit_tests/dataframe_test.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 an incremental AI Review.

  • /review full - 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

@aminghadersohi
aminghadersohi requested review from rebenitez1802 and removed request for rusackas September 29, 2026 03:26

@rusackas rusackas 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.

Nice, this is a clean extraction. The trusted-scalar/hostile-object handling is careful (love the tests that assert hooks never fire on subclassed values), and the Decimal/longdouble/NaN edge cases all look covered. Codeant and Bito's threads look addressed too. LGTM, approving.

@rusackas
rusackas merged commit db87cd2 into apache:master Sep 29, 2026
78 of 80 checks passed
villebro added a commit that referenced this pull request Oct 9, 2026
The duplicate-column-name tests cherry-picked from #44189 use
pytest.mark.parametrize, but on 7.0 result_set_test.py never imported
pytest: on master that import arrived with #44739, which builds on the
excluded #44219 and is not on 7.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants