codewithdaniel1 commented on issue #33206: URL: https://github.com/apache/superset/issues/33206#issuecomment-5139018620
Hi, I opened a PR for this issue here: https://github.com/apache/superset/pull/42625 During investigation, I found that the issue appears to come from how SQLAlchemy infers the type for expanding `IN` parameters from the first value in the list. For example, when the integer value appears first: ```python [21, 21.8, 25.35] ``` the compiled SQL can become: ```sql IN (21, 21, 25) ``` But when a decimal value appears first: ```python [21.8, 21, 25.35] ``` the decimals are preserved: ```sql IN (21.8, 21, 25.35) ``` The PR avoids converting integers to floats, since that could create precision issues for large integer values. Instead, it only reorders mixed integer/decimal numeric `IN` lists so that a decimal value appears first. SQL `IN` list ordering does not affect filter semantics, but it prevents later decimal values from being coerced to integers. I also added regression tests for the integer-first and decimal-first cases. Local validation: ```bash python -m pytest tests/unit_tests/models/helpers_test.py \ -k "numeric_in_filter_preserves" -q ``` ```text 2 passed, 147 deselected, 1 warning ``` ```bash python -m pytest tests/unit_tests/models/helpers_test.py -q ``` ```text 149 passed, 1 warning ``` ```bash pre-commit run --files superset/models/helpers.py tests/unit_tests/models/helpers_test.py ``` ```text Passed ``` -- 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]
