bito-code-review[bot] commented on code in PR #44219:
URL: https://github.com/apache/superset/pull/44219#discussion_r4012150151


##########
superset/dataframe.py:
##########
@@ -34,45 +43,54 @@ def _convert_big_integers(val: Any) -> Any:
     :returns: the same value but recast as a string if it was an integer over
         ``JS_MAX_INTEGER``
     """
-    return str(val) if isinstance(val, int) and abs(val) > JS_MAX_INTEGER else 
val
-
-
-def _is_na(val: Any) -> bool:
-    """
-    Check if a value is NA/NaN for scalar values only.
-
-    pd.isna() raises ValueError for arrays/lists, so we catch that case.
-
-    :param val: the value to check
-    :returns: True if the value is NA/NaN, False otherwise
-    """
-    try:
-        return bool(pd.isna(val))
-    except ValueError:
-        # pd.isna raises ValueError for arrays (e.g., lists, dicts from JSON)
-        return False
-
-
-def df_to_records(dframe: pd.DataFrame) -> list[dict[str, Any]]:
+    return str(val) if type(val) is int and abs(val) > JS_MAX_INTEGER else val
+
+
+def _is_trusted_missing_or_nonfinite(value: Any) -> bool:
+    """Recognize producer nulls without consulting object-column hooks."""
+    value_type = type(value)
+    if value_type in _PANDAS_MISSING_TYPES:
+        return True
+    if value_type is Decimal:
+        return not Decimal.is_finite(value)
+    if value_type is float:
+        return not math.isfinite(value)
+    if value_type in _NUMPY_FLOAT_TYPES:
+        return not math.isfinite(float(value))
+    return False

Review Comment:
   <!-- Bito Reply -->
   The suggestion provided by the reviewer is correct and appropriate to apply. 
Using `np.isfinite(value)` is the correct approach for handling `np.longdouble` 
types, as it avoids the overflow to `inf` that occurs when casting to a 
standard float via `math.isfinite(float(value))`, which would otherwise lead to 
incorrect data loss.
   
   **superset/dataframe.py**
   ```
   if value_type in _NUMPY_FLOAT_TYPES:
           return not np.isfinite(value)
   ```



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