aminghadersohi commented on code in PR #44695:
URL: https://github.com/apache/superset/pull/44695#discussion_r4139897510


##########
superset/db_engine_specs/gsheets.py:
##########
@@ -64,6 +66,43 @@
 ma_plugin = MarshmallowPlugin()
 
 
+def _to_python_value(value: Any) -> Any:
+    """
+    Convert numpy and pandas scalars into their Python equivalents.
+    """
+    if isinstance(value, np.datetime64):
+        # ``.item()`` returns an int for nanosecond precision; go through 
pandas.
+        value = pd.Timestamp(value)
+    elif isinstance(value, np.generic):
+        # e.g. ``np.timedelta64.item()`` returns a ``timedelta``.
+        value = value.item()

Review Comment:
   Reverified run #99088b at ddfec16e01a4f603476c49bdf41d61a48bbf884c. The 
original fix is 6211f59beff6d8d7df526226a7015a38912eee29: 
`superset/db_engine_specs/gsheets.py:76-86` handles `np.timedelta64` via 
`pd.Timedelta` before the generic `.item()` branch. Thus nanosecond durations 
do not become integer payloads.
   
   Evidence: `test_to_json_value_numpy_dates_and_durations` checks 5 ns → 
`"0:00:00"`, 90,000,000,000 ns → `"0:01:30"`, and NaT → None. The new 
`test_upload_cell_types[ns-duration]` in ddfec16e01 additionally checks the 
actual upload JSON for 5 ns, 90 seconds in ns, and a missing duration → empty 
string. All 78 GSheets tests and the 12 applicable pre-commit hooks pass. This 
thread is already resolved and remains so.
   



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