我怎样才能在 pyspark 中执行相当于interval '12' month
from SQLdate_parse(due_date, '%Y%m%d')- interval '12' month
的操作?(我的pyspark代码如下)
(df1.join(df2, ['a', 'b'], how='left')
.filter(F.col('date1') < F.col('date2'))
.filter(F.col('date1') > F.col('date2') - interval '12' month)
.groupby(['a','b']).count()
.cache())
在上面的代码中date1
并且date2
都是 cast to_date
。
试试这个:
(df1.join(df2, ['a', 'b'], how='left')
.filter(F.col('date1') < F.col('date2'))
.filter(F.months_between(F.col('date2'), F.col('date1')) < 12 )
.groupby(['a','b']).count()
.cache())
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句