簡體   English   中英

Spark 2.1.0,執行第二次連接時無法解析列名

[英]Spark 2.1.0, cannot resolve column name when doing second join

我有三個表,並且兩個表都在一個表中,因此我在A&B = D上進行了聯接

現在,我要完成與D&C的加入

問題是我收到此錯誤:

org.apache.spark.sql.AnalysisException: Cannot resolve column name "ClaimKey" among (_1, _2);
  at org.apache.spark.sql.Dataset$$anonfun$resolve$1.apply(Dataset.scala:219)

這是來自齊柏林飛艇的實際代碼:

joinedperson.printSchema
filteredtable.printSchema
val joined = joinedperson.joinWith(filteredtable, 
    filteredtable.col("ClaimKey") === joinedperson.col("ClaimKey"))

這些是我嘗試連接的兩個表的架構,問題出在第一個架構中的ClaimKey。

root
 |-- _1: struct (nullable = false)
 |    |-- clientID: string (nullable = true)
 |    |-- PersonKey: string (nullable = true)
 |    |-- ClaimKey: string (nullable = true)
 |-- _2: struct (nullable = false)
 |    |-- ClientID: string (nullable = true)
 |    |-- MyPersonKey: string (nullable = true)
root
 |-- clientID: string (nullable = true)
 |-- ClaimType: string (nullable = true)
 |-- ClaimKey: string (nullable = true)

我已經從實木復合地板文件中讀取了原始數據,然后使用案例類將行映射到類中,並具有數據集。

我希望這是由於元組的緣故,那么我該如何加入呢?

您的第一個DataFrame的結構是嵌套的 ClaimKey是另一個字段( _1 )內的一個字段; 要訪問這樣的字段,您可以簡單地為該字段提供“路由”,並以點分隔父字段:

val joined = joinedperson.joinWith(filteredtable, 
  filteredtable.col("ClaimKey") === joinedperson.col("_1.ClaimKey"))

暫無
暫無

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

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