我正在使用Spark 1.3,并希望使用Python接口(SparkSQL)在多个列上进行连接。
以下代码是有效的:
我首先将它们注册为临时表。
以下代码是有效的:
我首先将它们注册为临时表。
numeric.registerTempTable("numeric")
Ref.registerTempTable("Ref")
test = numeric.join(Ref, numeric.ID == Ref.ID, joinType='inner')
我现在想根据多列进行连接。
使用以下代码会出现SyntaxError
: invalid syntax错误:
test = numeric.join(Ref,
numeric.ID == Ref.ID AND numeric.TYPE == Ref.TYPE AND
numeric.STATUS == Ref.STATUS , joinType='inner')
df1.x1 == df2.x1 & df1.x2 == df2.x2
(括号已删除)将被Python解释器评估为df1.x1 == (df2.x1 & df1.x2) == df2.x2
,这可能会引发混乱和不具描述性的错误。 - Brendanx1
和x2
? - Bikash Gyawali