簡體   English   中英

PySpark where 子句條件條件

[英]PySpark where clause condition on condition

我在以下查詢中收到語法錯誤:

df_result = df_checkout.join(df_checkin, 
                                    (
                                    (df_checkout.product == df_checkin.product)
                                    (df_checkout.host == df_checkin.host)
                                    ),
                                    how = 'full_outer').where(df_checkout.rank = 
                                        F.when(((df_checkout.rank = df_checkin.rank) and (F.unix_timestamp(df_checkout.checkout_date, 'MM/dd/YYYY HH:MI:SS') <= F.unix_timestamp(df_checkin.checkin_date, 'MM/dd/YYYY HH:MI:SS'))), (df_checkin.rank - 1)).when(((df_checkout.rank = df_checkin.rank) and (F.unix_timestamp(df_checkout.checkout_date, 'MM/dd/YYYY HH:MI:SS') >= F.unix_timestamp(df_checkin.checkin_date, 'MM/dd/YYYY HH:MI:SS'))), df_checkin.rank).otherwise(None)
                                    )

我遇到了什么錯誤?

你有一個=而不是==

(df_checkout.rank = df_checkin.rank)

應該

(df_checkout.rank == df_checkin.rank)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM