ramiroaquinoromero commented on code in PR #37071:
URL: https://github.com/apache/superset/pull/37071#discussion_r2715168269
##########
superset/dataframe.py:
##########
@@ -52,6 +55,11 @@ def df_to_records(dframe: pd.DataFrame) -> list[dict[str,
Any]]:
for record in records:
for key in record:
- record[key] = _convert_big_integers(record[key])
+ val = record[key]
+ # Convert NaN/NA values to None for JSON compatibility
+ if pd.isna(val):
+ record[key] = None
+ else:
+ record[key] = _convert_big_integers(val)
Review Comment:
Done
##########
tests/unit_tests/dataframe_test.py:
##########
@@ -203,3 +203,91 @@ def test_max_pandas_timestamp(input_, expected) -> None:
df = results.to_pandas_df()
assert df_to_records(df) == expected
+
+
+def test_df_to_records_with_nan_from_division_by_zero() -> None:
+ """Test that NaN values from division by zero are converted to None."""
+ import numpy as np
+
+ from superset.db_engine_specs import BaseEngineSpec
+ from superset.result_set import SupersetResultSet
Review Comment:
Done
--
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]