pyspark.sql.functions.years

pyspark.sql.functions.years(col: ColumnOrName) → pyspark.sql.column.Column

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

Notes

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

Examples

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