在进行 pyspark 数据帧自加入时,我收到一条错误消息:
Py4JJavaError: An error occurred while calling o1595.join.
: org.apache.spark.sql.AnalysisException: Resolved attribute(s) un_val#5997 missing from day#290,item_listed#281,filename#286 in operator !Project [...]. Attribute(s) with the same name appear in the operation: un_val. Please check if the right attribute(s) are used.;;
这是一个简单的数据框自连接,如下面的,它工作正常,但是在对数据框进行一些操作(如添加列或与其他数据框连接)后,会引发上述错误。
df.join(df,on='item_listed')
使用像下面这样的数据框别名也不起作用,并且会引发相同的错误消息:
df.alias('A').join(df.alias('B'), col('A.my_id') == col('B.my_id'))