current_time
Returns the current time at the start of query evaluation as a TimeType column. All calls of current_time within the same query return the same value.
Syntax
Python
from pyspark.databricks.sql import functions as dbf
dbf.current_time(precision=<precision>)
Parameters
Parameter | Type | Description |
|---|---|---|
|
| Number in the range [0..6], indicating how many fractional digits of seconds to include. If omitted, the default is 6. |
Returns
pyspark.sql.Column: Current time.
Examples
Example 1: Current time with default precision
Python
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.current_time().alias("time")).show()
Output
+---------------+
| time|
+---------------+
|16:57:04.304361|
+---------------+
Example 2: Current time with specified precision
Python
from pyspark.databricks.sql import functions as dbf
spark.range(1).select(dbf.current_time(3).alias("time")).show()
Output
+------------+
| time|
+------------+
|16:57:04.304|
+------------+