gpt4 book ai didi

java - 如何解决 AnalysisException : resolved attribute(s) in Spark

转载 作者:IT老高 更新时间:2023-10-28 20:53:02 27 4
gpt4 key购买 nike

val rdd = sc.parallelize(Seq(("vskp", Array(2.0, 1.0, 2.1, 5.4)),("hyd",Array(1.5, 0.5, 0.9, 3.7)),("hyd", Array(1.5, 0.5, 0.9, 3.2)),("tvm", Array(8.0, 2.9, 9.1, 2.5))))
val df1= rdd.toDF("id", "vals")
val rdd1 = sc.parallelize(Seq(("vskp","ap"),("hyd","tel"),("bglr","kkt")))
val df2 = rdd1.toDF("id", "state")
val df3 = df1.join(df2,df1("id")===df2("id"),"left")

连接操作工作正常但是当我重用 df2 时,我面临 Unresolved 属性错误

val rdd2 = sc.parallelize(Seq(("vskp", "Y"),("hyd", "N"),("hyd", "N"),("tvm", "Y")))
val df4 = rdd2.toDF("id","existance")
val df5 = df4.join(df2,df4("id")===df2("id"),"left")

ERROR: org.apache.spark.sql.AnalysisException: resolved attribute(s)id#426

最佳答案

正如我在评论中提到的,它与 https://issues.apache.org/jira/browse/SPARK-10925 有关更具体地说https://issues.apache.org/jira/browse/SPARK-14948 .重复使用引用会在命名中产生歧义,因此您必须克隆 df - 请参阅 https://issues.apache.org/jira/browse/SPARK-14948 中的最后一条评论举个例子。

关于java - 如何解决 AnalysisException : resolved attribute(s) in Spark,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45713290/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com