You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "uros-b (via GitHub)" <gi...@apache.org> on 2026/06/20 00:07:24 UTC
Re: [PR] [SPARK-55299][PS] Infer the correct unit for calculated timedeltas [spark]
uros-b commented on code in PR #56624:
URL: https://github.com/apache/spark/pull/56624#discussion_r3444997977
##########
python/pyspark/pandas/data_type_ops/timedelta_ops.py:
##########
@@ -72,6 +73,35 @@ def restore(self, col: pd.Series) -> pd.Series:
else:
return col.astype(self.dtype)
+ def _with_inferred_unit(
+ self, result: SeriesOrIndex, left: IndexOpsLike, right: Union[IndexOpsMixin, timedelta]
+ ) -> SeriesOrIndex:
+ # pandas 3.0.0+ promotes timedelta arithmetic to the finer resolution of the
+ # operands; before that timedelta64 is always nanoseconds.
Review Comment:
The last part is a bit imprecisely worded. pandas 2.0 introduced non-nanosecond resolution, so timedelta64[s]/[ms]/[us] have existed in plain pandas since well before 3.0.0.
Perhaps a better note would be `; before that, pandas-on-Spark represented timedelta as nanoseconds.`.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org