korbit-ai[bot] commented on code in PR #33230:
URL: https://github.com/apache/superset/pull/33230#discussion_r2058892954


##########
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:
   The code still has redundant casting. After converting to float, 
cast_to_num() is unnecessary. Also, if float() fails, passing the original 
value to cast_to_num() could trigger another error.
   
   Consider this simpler approach:
   ```python
   try:
       return float(value)  # Single cast is sufficient
   except ValueError:
       logger.error(f"Unable to cast value {value} to num")
       return None  # Or raise an appropriate exception
   ```



-- 
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