Nota
Capaian ke halaman ini memerlukan kebenaran. Anda boleh cuba mendaftar masuk atau menukar direktori.
Capaian ke halaman ini memerlukan kebenaran. Anda boleh cuba menukar direktori.
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()