codeant-ai-for-open-source[bot] commented on code in PR #44695:
URL: https://github.com/apache/superset/pull/44695#discussion_r4113508814


##########
superset/db_engine_specs/gsheets.py:
##########
@@ -64,6 +66,28 @@
 ma_plugin = MarshmallowPlugin()
 
 
+def to_json_value(value: Any) -> Any:
+    """
+    Convert a dataframe cell into a JSON value the Sheets API parses back.
+
+    Dates and timestamps become ISO strings (``USER_ENTERED`` input parses them
+    as dates), and numpy scalars become Python scalars.
+    """
+    if value is None:
+        return None
+    if isinstance(value, pd.Timestamp):
+        value = value.to_pydatetime()
+    if isinstance(value, datetime):
+        return value.isoformat(sep=" ")
+    if isinstance(value, (date, time)):
+        return value.isoformat()
+    if isinstance(value, Decimal):
+        return str(value)
+    if isinstance(value, np.generic):
+        return value.item()

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `2f9e931`.
   
   The conversion now normalizes `pd.Timestamp` and `pd.Timedelta` to Python 
values, and `to_json_value` serializes resulting `datetime` and `timedelta` 
values as strings.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



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