Мне нужно обновить значение задержки для штрих-кода (offset=1
) до штрих-кода
case
when ( lag(barcode,1) over (order by barcode )
and Datediff(SS, eventdate,lag(next_eventdate,1) over (order by barcode)) < 3*3600 )
THEN 1
ELSE 0
END as FLAG
Я реализовал его в pyspark, но выдает ошибку
from pyspark.sql.functions import col, unix_timestamp
timeDiff = unix_timestamp('eventdate', format="ss")- unix_timestamp(F.lag('next_eventdate', 1), format="ss")
ww= Window.orderBy("barcode")
Tgt_df_tos = Tgt_df_7.withColumn('FLAG',F.when((F.lag('barcode', 1)) & ( timeDiff <= 10800),"1").otherwise('0'))
Ошибка, которую я получаю
AnalysisException: "cannot resolve '(lag(`barcode`, 1, NULL) AND ((unix_timestamp(`eventdate`, 'ss') - unix_timestamp(lag(`next_eventdate`, 1, NULL), 'ss')) <= CAST(10800 AS BIGINT)))' due to data type mismatch: differing types in '(lag(`barcode`, 1, NULL) AND ((unix_timestamp(`eventdate`, 'ss') - unix_timestamp(lag(`next_eventdate`, 1, NULL), 'ss')) <= CAST(10800 AS BIGINT)))' (int and boolean).