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


##########
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:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>longdouble overflow nulls data</b></div>
   <div id="fix">
   
   `math.isfinite(float(value))` overflows finite `np.longdouble` values above 
float64 max (e.g. `np.longdouble('1e400')`) to `inf`, so 
`_is_trusted_missing_or_nonfinite` returns True and the value is silently 
converted to None (data loss). Use `np.isfinite(value)` instead, which handles 
longdouble correctly.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
       if value_type in _NUMPY_FLOAT_TYPES:
           return not np.isfinite(value)
       return False
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #c713d3</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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