ich Hivecontext bin mit einer JSON-Datei mit folgendem Code zu lesen:lesen Json Datei mit Apache Spark-
df = hive_context.read.json("/Users/duttaam/Downloads/test.json")
df.registerTempTable("df");
standardmäßig Funken bestimmt das folgende Schema
root
|-- id: string (nullable = true)
|-- profiles: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- app_id: string (nullable = true)
| | |-- localytics: struct (nullable = true)
| | | |-- attributes: struct (nullable = true)
| | | | |-- ap: long (nullable = true)
| | | | |-- app_version: string (nullable = true)
| | | | |-- birthdate: string (nullable = true)
| | | | |-- country: string (nullable = true)
| | | | |-- device_timezone: string (nullable = true)
| | | | |-- language: string (nullable = true)
| | | | |-- last_session_date: string (nullable = true)
| | | | |-- library_version: string (nullable = true)
| | | | |-- os_version: string (nullable = true)
| | | | |-- push_enabled: long (nullable = true)
| | | | |-- total_sessions: long (nullable = true)
| | | | |-- user_type: string (nullable = true)
Meine Json wie sieht wie folgt aus
{
"id": "dsdasdasdsd",
"profiles": [
{
"attributes": {
"MDN": "eoe/W/5Ru1KAPDMQQ/wq\n/pu/tGRWpA=="
},
"localytics": {
"attributes": {
"last_session_date": "2016-07-17",
"device_timezone": "-04:00",
"country": "us",
"language": "en",
"user_type": "known",
"city_name": "Indianapolis"
}
}
},
{
"app_id": "sdas-c824fcf6-bbae-11e5-adasda-asasqwvz",
"attributes": {
"Automatic Backup User": "No"
},
"localytics": {
"attributes": {
"last_session_date": "2016-07-17",
"os_version": "6.2.1",
"app_version": "16.2.19.1",
"library_version": "androida_3.7.0",
"ap": 1,
"custom_1": "Unknown (Not Logged In)",
"total_sessions": 4,
"birthdate": "2016-07-09",
"push_enabled": 1,
"user_type": "known",
"custom_0": "Unknown (Not Logged In)",
"seconds_since_last_session": 1457
}
}
}
]
}
So nimmt Spark standardmäßig keine Attributfelder in beiden Profilen auf. Gibt es eine Möglichkeit, die Anzeigenstruktur zu ändern, um die Schema-Struktur zu ändern?
Vielen Dank im Voraus.
Grüße, Amit
why -ive vote? Ist das keine gültige Frage? – Dutta