codewithdaniel1 opened a new pull request, #42625:
URL: https://github.com/apache/superset/pull/42625

   ### 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:
   
   ```python
   [21, 21.8, 25.35]
   ```
   
   could compile as:
   
   ```sql
   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:
   
   ```bash
   python -m pytest tests/unit_tests/models/helpers_test.py \
     -k "numeric_in_filter_preserves_decimals_when_integer_is_first" -q
   ```
   
   Result:
   
   ```text
   1 passed, 147 deselected, 1 warning
   ```
   
   Ran the full helper test file:
   
   ```bash
   python -m pytest tests/unit_tests/models/helpers_test.py -q
   ```
   
   Result:
   
   ```text
   148 passed, 1 warning
   ```
   
   Ran pre-commit on the changed files:
   
   ```bash
   pre-commit run --files superset/models/helpers.py 
tests/unit_tests/models/helpers_test.py
   ```
   
   Result:
   
   ```text
   Passed after ruff-format reformatted one file.
   ```
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #33206
   - [ ] Required feature flags
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] 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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to