【发布时间】:2022-01-16 15:00:40
【问题描述】:
我有按列分区的 DataFrame:
val dfDL = spark.read.option("delimiter", ",")
.option("header", true)
.csv(file.getPath.toUri.getPath)
.repartition(col("column_to"))
val structure = "schema_from" ::
"table_from" ::
"column_from" ::
"link_type" ::
"schema_to" ::
"table_to" ::
"column_to" :: Nil
如何按分区获取数组集合? 也就是说,对于每个分区,我都需要一个集合。 比如我需要这个方法:
def getArrays(df: DataFrame): Iterator[Array] = { //Or Iterator[List]
???
}
分区的所有值:
val allTargetCol = df.select(col("column_to")).distinct().collect().map(_.getString(0))
【问题讨论】:
标签: dataframe scala apache-spark collections partitioning