Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
Returns time truncated to the unit.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.time_trunc(unit=<unit>, time=<time>)
Parameters
| Parameter | Type | Description |
|---|---|---|
unit |
pyspark.sql.Column or str |
The unit to truncate the time to. Supported units are: "HOUR", "MINUTE", "SECOND", "MILLISECOND", and "MICROSECOND". The unit is case-insensitive. |
time |
pyspark.sql.Column or str |
A time to truncate. |
Returns
pyspark.sql.Column: A time truncated to the specified unit.
Examples
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame(
[("HOUR", "13:08:15")],
['unit', 'time']).withColumn("time", dbf.col("time").cast("time"))
df.select('*', dbf.time_trunc('unit', 'time')).show()