Ich habe eine Spalte in einer Tabelle Hive:Wie wird Array [Struct [String, String]] in Hive to Array [Map [String, String]] umgewandelt?
Spaltenname: Filter
Daten-Typ:
|-- filters: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- name: string (nullable = true)
| | |-- value: string (nullable = true)
Ich möchte den Wert aus dieser Spalte erhalten, indem sie Namen entsprechend ist.
Was ich bisher tat:
val sdf: DataFrame = sqlContext.sql("select * from <tablename> where id='12345'")
val sdfFilters = sdf.select("filters").rdd.map(r => r(0).asInstanceOf[Seq[(String,String)]]).collect()
Output: sdfFilters: Array[Seq[(String, String)]] = Array(WrappedArray([filter_RISKFACTOR,OIS.SPD.*], [filter_AGGCODE,IR]), WrappedArray([filter_AGGCODE,IR_]))
Hinweis: Casting Seq weil WrappedArray Umstellung auf Karte ist nicht möglich.
Was nun zu tun?
Ich möchte die Werte b und c als Sequenz oder Array von String nicht als Zeilenobjekt erhalten. –
Funktioniert das? –
Ich habe die Antwort aktualisiert –