uros-b commented on code in PR #56626:
URL: https://github.com/apache/spark/pull/56626#discussion_r3448565940
##########
python/pyspark/sql/functions/builtin.py:
##########
@@ -11792,6 +11792,57 @@ def unix_millis(col: "ColumnOrName") -> Column:
return _invoke_function_over_columns("unix_millis", col)
+@_try_remote_functions
+def unix_nanos(col: "ColumnOrName") -> Column:
+ """Returns the number of nanoseconds since 1970-01-01 00:00:00 UTC as
``DECIMAL(21, 0)``.
+ Only supported for ``TIMESTAMP_LTZ(p)`` and ``TIMESTAMP_NTZ(p)`` with
precision ``p``
+ in ``[7, 9]``.
+
+ .. versionadded:: 4.3.0
+
+ Parameters
+ ----------
+ col : :class:`~pyspark.sql.Column` or column name
+ input column of nanosecond-precision timestamp values to convert.
+
+ Returns
+ -------
+ :class:`~pyspark.sql.Column`
+ the number of nanoseconds since 1970-01-01 00:00:00 UTC as
``DECIMAL(21, 0)``.
+
+ See Also
+ --------
+ :meth:`pyspark.sql.functions.unix_date`
+ :meth:`pyspark.sql.functions.unix_seconds`
+ :meth:`pyspark.sql.functions.unix_millis`
+ :meth:`pyspark.sql.functions.unix_micros`
+
+ Examples
+ --------
+ >>> import pyspark.sql.functions as sf
+ >>> spark.conf.set("spark.sql.timestampNanosTypes.enabled", True)
Review Comment:
Nit: The new doctest uses a Python bool value (`True`), but every other
doctest in `builtin.py` uses the string form, e.g.
`spark.conf.set("spark.sql.ansi.enabled", "true")`. It works (the value is
coerced to "True" and the boolean conf parser is case-insensitive), but "true"
would be more consistent with the file's convention.
--
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]