In Pyspark - 表Aのcolumn(listed_1)
の列値をの値でwhere condition (B.list_expire_value) > 5 || (B.list_date) < 6
に設定する方法。 (B)は、それらが表Bの列であることを示すことです。pysparkの異なるテーブルから列の値を設定するには?
spark_df = table_1.join("table_2", on ="uuid").when((table_2['list_expire_value'] > 5) | (table_2['list_date'] < 6)).withColumn("listed_1", table_2['list_date'])
をしかし、私はエラーを取得しています:
現在、私はやっています。これを行う方法?
Sample table : Table A uuid listed_1 001 abc 002 def 003 ghi Table B uuid list_date list_expire_value col4 001 12 7 dckvfd 002 14 3 dfdfgi 003 3 8 sdfgds Expected Output uuid listed1 list_expire_value col4 001 12 7 dckvfd 002 def 3 dfdfgi 003 3 8 sdfgds 002 of listed1 will not be replaced since they do not fufil the when conditions.
@mtotoは、出力が期待される追加された。忘れてはいけません – Viv
@tbone、sqlContextを使用すると、Update文になり、col value = xに設定されます。それは火花の権利で許可されていません? – Viv
いいえ、SQL結合の結果である新しいデータフレームを作成してください – tbone