Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Make year-month interval from years, months.
For the corresponding Databricks SQL function, see make_ym_interval function.
Syntax
from pyspark.databricks.sql import functions as dbf
dbf.make_ym_interval(years=<years>, months=<months>)
Parameters
| Parameter | Type | Description |
|---|---|---|
years |
pyspark.sql.Column or str, optional |
The number of years, positive or negative |
months |
pyspark.sql.Column or str, optional |
The number of months, positive or negative |
Returns
pyspark.sql.Column: A new column that contains a year-month interval.
Examples
spark.conf.set("spark.sql.session.timeZone", "America/Los_Angeles")
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([[2014, 12]], ['year', 'month'])
df.select('*', dbf.make_ym_interval('year', df.month)).show(truncate=False)
df = spark.createDataFrame([[2014, 12]], ['year', 'month'])
df.select('*', dbf.make_ym_interval(df.year)).show(truncate=False)
spark.range(1).select(dbf.make_ym_interval()).show(truncate=False)
spark.conf.unset("spark.sql.session.timeZone")