Comment puis-je créer une Étincelle DataFrame à partir d'un tableau imbriqué de struct element?

J'ai lu un fichier JSON dans Spark. Ce fichier a la structure suivante:

scala> tweetBlob.printSchema
root
 |-- related: struct (nullable = true)
 |    |-- next: struct (nullable = true)
 |    |    |-- href: string (nullable = true)
 |-- search: struct (nullable = true)
 |    |-- current: long (nullable = true)
 |    |-- results: long (nullable = true)
 |-- tweets: array (nullable = true)
 |    |-- element: struct (containsNull = true)
 |    |    |-- cde: struct (nullable = true)
...
...
 |    |    |-- cdeInternal: struct (nullable = true)
...
...
 |    |    |-- message: struct (nullable = true)
...
...

Ce que je voudrais idéalement veux, c'est un DataFrame avec des colonnes "cde", "cdeInternal", "message"... comme illustré ci-dessous

root
|-- cde: struct (nullable = true)
...
...
|-- cdeInternal: struct (nullable = true)
...
...
|-- message: struct (nullable = true)
...
...

J'ai réussi à utiliser une "explosion" d'en extraire des éléments les "tweets" tableau dans une colonne appelée "tweets"

scala> val tweets = tweetBlob.select(explode($"tweets").as("tweets"))
tweets: org.apache.spark.sql.DataFrame = [tweets: struct<cde:struct<author:struct<gender:string,location:struct<city:string,country:string,state:string>,maritalStatus:struct<evidence:string,isMarried:string>,parenthood:struct<evidence:string,isParent:string>>,content:struct<sentiment:struct<evidence:array<struct<polarity:string,sentimentTerm:string>>,polarity:string>>>,cdeInternal:struct<compliance:struct<isActive:boolean,userProtected:boolean>,tracks:array<struct<id:string>>>,message:struct<actor:struct<displayName:string,favoritesCount:bigint,followersCount:bigint,friendsCount:bigint,id:string,image:string,languages:array<string>,link:string,links:array<struct<href:string,rel:string>>,listedCount:bigint,location:struct<displayName:string,objectType:string>,objectType:string,postedTime...
scala> tweets.printSchema
root
|-- tweets: struct (nullable = true)
|    |-- cde: struct (nullable = true)
...
...
|    |-- cdeInternal: struct (nullable = true)
...
...
|    |-- message: struct (nullable = true)
...
...

Comment puis-je sélectionner toutes les colonnes à l'intérieur de la structure et de créer un DataFrame? Exploser ne fonctionne pas sur une struct si ma compréhension est correcte.

Toute aide est appréciée.

La Question a également demandé à Databricks forum, mais pas de réponse.

OriginalL'auteur zapstar | 2015-11-23