架构:
|-- c0: string (nullable = true)
|-- c1: struct (nullable = true)
| |-- c2: array (nullable = true)
| | |-- element: struct (containsNull = true)
| | | |-- orangeID: string (nullable = true)
| | | |-- orangeId: string (nullable = true)
Run Code Online (Sandbox Code Playgroud)
我试图在火花中展平上面的架构。
码:
var df = data.select($"c0",$"c1.*").select($"c0",explode($"c2")).select($"c0",$"col.orangeID", $"col.orangeId")
Run Code Online (Sandbox Code Playgroud)
拼合代码工作正常。问题出在最后一部分,其中两列的区别仅在于1个字母(orangeID和orangeId)。因此,我收到此错误:
错误:
org.apache.spark.sql.AnalysisException: Ambiguous reference to fields StructField(orangeID,StringType,true), StructField(orangeId,StringType,true);
Run Code Online (Sandbox Code Playgroud)
任何避免这种歧义的建议都是很好的。