Существующие столбцы DF:
|-- col1: string (nullable = true)
|-- col2: string (nullable = true)
|-- col3: struct (nullable = true)
| |-- col3_1: struct (nullable = true)
| | |-- colA: string (nullable = true)
| |-- col3_2: struct (nullable = true)
| | |-- colB: string (nullable = true)
|-- col4: string (nullable = true)
|-- col5: string (nullable = true)
Мне нужно прочитать только следующие столбцы:
col1,col2, col3,
Для первых 2 столбцов я могу создать следующую схему:
val schema = StructType(Array(StructField("col1", StringType), StructField("col2", LongType)))
Схема для вложенной структуры:
StructType(Array(StructField("col1", StringType),
StructField("col3", StructType(StructField("col3_1",StructType(StructField("colA",StringType))),StructField("col3_2",StructType(StructField("colB",StringType)))))
Ошибка:
error: overloaded method value apply with alternatives:
Любые предложения по созданию схемы для вложенной структуры