Skip to content

fix: preserve decimals in mixed numeric IN filters - #42625

Open
codewithdaniel1 wants to merge 2 commits into
apache:masterfrom
codewithdaniel1:investigate-numeric-filter-33206
Open

fix: preserve decimals in mixed numeric IN filters#42625
codewithdaniel1 wants to merge 2 commits into
apache:masterfrom
codewithdaniel1:investigate-numeric-filter-33206

Conversation

@codewithdaniel1

@codewithdaniel1 codewithdaniel1 commented Jul 31, 2026

Copy link
Copy Markdown

SUMMARY

Fixes #33206.

This fixes numeric IN filters where selecting an integer value before decimal values could cause later decimal values to be coerced to integers when SQLAlchemy compiles the query.

For example, a mixed numeric filter like:

[21, 21.8, 25.35]

could compile as:

IN (21, 21, 25)

because SQLAlchemy infers the expanding IN parameter type from the first value.

This change preserves the original numeric values and only reorders mixed integer/decimal IN lists so that a decimal value appears first. SQL IN list ordering does not affect filter semantics, but it prevents decimal values from being coerced to integers.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable. This is a backend SQL generation fix covered by a unit regression test.

TESTING INSTRUCTIONS

Ran the targeted regression test:

python -m pytest tests/unit_tests/models/helpers_test.py \
  -k "numeric_in_filter_preserves_decimals_when_integer_is_first" -q

Result:

2 passed, 147 deselected, 1 warning

Ran the full helper test file:

python -m pytest tests/unit_tests/models/helpers_test.py -q

Result:

149 passed, 1 warning

Ran pre-commit on the changed files:

pre-commit run --files superset/models/helpers.py tests/unit_tests/models/helpers_test.py

Result:

Passed after ruff-format reformatted one file.

ADDITIONAL INFORMATION

  • Has associated issue: Fixes Incorrect filtering for numeric values with different decimal precision #33206
  • 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

@dosubot dosubot Bot added change:backend Requires changing the backend explore:filter Related to filters in Explore labels Jul 31, 2026
@bito-code-review

bito-code-review Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #d8a6f7

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 42cc7d6..42cc7d6
    • superset/models/helpers.py
    • tests/unit_tests/models/helpers_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 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

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.44%. Comparing base (7b351d5) to head (32d862d).

Files with missing lines Patch % Lines
superset/models/helpers.py 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #42625      +/-   ##
==========================================
- Coverage   65.44%   65.44%   -0.01%     
==========================================
  Files        2810     2810              
  Lines      159362   159365       +3     
  Branches    36372    36373       +1     
==========================================
- Hits       104294   104291       -3     
- Misses      53026    53030       +4     
- Partials     2042     2044       +2     
Flag Coverage Δ
hive 38.08% <0.00%> (-0.01%) ⬇️
mysql 57.82% <0.00%> (-0.01%) ⬇️
postgres 57.86% <0.00%> (-0.01%) ⬇️
presto 39.98% <0.00%> (-0.01%) ⬇️
python 59.25% <0.00%> (-0.01%) ⬇️
sqlite 57.49% <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.

@bito-code-review

bito-code-review Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #3ea6a8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 42cc7d6..32d862d
    • tests/unit_tests/models/helpers_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 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

change:backend Requires changing the backend explore:filter Related to filters in Explore size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect filtering for numeric values with different decimal precision

1 participant