1
2
3
4
5
6
7
8
9
def flattenSchema(schema: StructType, prefix: String = null): Array[Column] = {
schema.fields.flatMap(f => {
val colName = if (prefix == null) f.name else (prefix + "." + f.name)
f.dataType match {
case st: StructType => flattenSchema(st, colName)
case _ => Array(col(colName) as colName)
}
})
}
중첩된 schema flattening하기
This post is licensed under CC BY 4.0 by the author.
Comments powered by Disqus.