Σημείωση
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να συνδεθείτε ή να αλλάξετε καταλόγους.
Η πρόσβαση σε αυτή τη σελίδα απαιτεί εξουσιοδότηση. Μπορείτε να δοκιμάσετε να αλλάξετε καταλόγους.
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()