korbit-ai[bot] commented on code in PR #33230:
URL: https://github.com/apache/superset/pull/33230#discussion_r2058806581
##########
superset/connectors/sqla/models.py:
##########
@@ -553,7 +560,11 @@ def handle_single_value(value: FilterValue | None) ->
FilterValue | None:
):
# For backwards compatibility and edge cases
# where a column data type might have changed
- return utils.cast_to_num(value)
+ try:
+ return utils.cast_to_num(float(value))
+ except ValueError:
+ logger.error(f"Unable to cast value {value} to num")
+ return utils.cast_to_num(value)
Review Comment:
### Redundant numeric casting fallback <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
When a ValueError occurs during float casting, the code falls back to the
original cast_to_num(value) which could trigger another error for the same
value.
###### Why this matters
The fallback behavior could mask the actual error and potentially cause
cascade failures by attempting the same problematic conversion through a
different path.
###### Suggested change ∙ *Feature Preview*
Return None or raise an appropriate error instead of attempting another cast:
```python
try:
return utils.cast_to_num(float(value))
except ValueError:
logger.error(f"Unable to cast value {value} to num")
return None
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/52987647-cdc1-46e2-b2c9-78c3c6f8d41a/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/52987647-cdc1-46e2-b2c9-78c3c6f8d41a?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/52987647-cdc1-46e2-b2c9-78c3c6f8d41a?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/52987647-cdc1-46e2-b2c9-78c3c6f8d41a?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/52987647-cdc1-46e2-b2c9-78c3c6f8d41a)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:b493de74-df07-481b-b2ce-64b52a4849a3 -->
[](b493de74-df07-481b-b2ce-64b52a4849a3)
--
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]