Skip to main content

years

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

warning

Deprecated in 4.0.0. Use partitioning.years instead.

Syntax​

Python
from pyspark.sql import functions as dbf

dbf.years(col=<col>)

Parameters​

Parameter

Type

Description

col

pyspark.sql.Column or str

Target date or timestamp column to work on.

Parameter

Type

Description

col

pyspark.sql.Column or str

Target date or timestamp column to work on.

Returns​

pyspark.sql.Column: Data partitioned by years.

Examples​

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

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