【发布时间】:2019-12-18 06:02:58
【问题描述】:
我有两个具有以下架构的表作为示例:
scala> df1.printSchema
root
|-- id: string (nullable = true)
AND
scala> df2.printSchema
root
|-- col1: string (nullable = true)
|-- col2: array (nullable = true)
| |-- element: string (containsNull = true)
我想获取 df2 中的所有 col1,其中 col2 数组中的元素等于 df1 中的 id。输出诸如 df3 之类的东西:
scala> df3.printSchema
root
|-- c1: array (nullable = true)
| |-- element: string (containsNull = true)
|-- c2: string (nullable = true)
其中 df3.c2 基本上是 df1.id 而 df3.c1 是满足上述相等性的所有 df2.col1 的数组。
任何 SQL (hive) 或 Scala 解决方案都非常有用。
【问题讨论】:
标签: sql scala dataframe join hive