pyspark.sql.functions.daysΒΆ

pyspark.sql.functions.days(col: ColumnOrName) → pyspark.sql.column.Column[source]ΒΆ

Partition transform function: A transform for timestamps and dates to partition data into days.

New in version 3.1.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

target date or timestamp column to work on.

Returns
Column

data partitioned by days.

Notes

This function can be used only in combination with partitionedBy() method of the DataFrameWriterV2.

Examples

>>> df.writeTo("catalog.db.table").partitionedBy(  
...     days("ts")
... ).createOrReplace()