Created
November 26, 2016 14:31
-
-
Save laughingman7743/954ba238a27f76336b4d42ff1137d17c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ADD JAR s3://YOUR_BUCKET_NAME/path/to/json-serde-1.3.7-jar-with-dependencies.jar; | |
CREATE EXTERNAL TABLE IF NOT EXISTS test.nested_json_table ( | |
column1 string, | |
column2 array<int>, | |
column3 struct< | |
nestedcolumn1: array<string>, | |
nestedcolumn2: array< | |
struct< | |
morenestedarraycolumn1: int, | |
morenestedarraycolumn2: array<string> | |
> | |
>, | |
nestedcolumn3: struct< | |
morenestedcolumn1: double, | |
morenestedcolumn2: string | |
> | |
> | |
) | |
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' STORED AS TEXTFILE | |
LOCATION 's3://YOUR_JSON_DATA_LOCATION/'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
column3.nestedcolumn3.morenestedcolumn1, | |
column3.nestedcolumn3.morenestedcolumn2 | |
FROM test.nested_json_table; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
t.morenestedarraycolumn1, | |
t.morenestedarraycolumn2 | |
FROM test.nested_json_table | |
LATERAL VIEW explode(column3.nestedcolumn2) nestedcolumn2 as t; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"column1": "value", | |
"column2": [1, 2, 3, 4, 5], | |
"column3": { | |
"nestedColumn1": ["value1", "value2", "value3"], | |
"nestedColumn2": [ | |
{ | |
"moreNestedArrayColumn1": 1, | |
"moreNestedArrayColumn2": ["a", "b"] | |
}, | |
{ | |
"moreNestedArrayColumn1": 2, | |
"moreNestedArrayColumn2": ["c", "d"] | |
} | |
], | |
"nestedColumn3": { | |
"moreNestedColumn1": 1.0, | |
"moreNestedColumn2": "value" | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"column1":"value","column2":[1,2,3,4,5],"column3":{"nestedColumn1":["value1","value2","value3"],"nestedColumn2":[{"moreNestedArrayColumn1":1,"moreNestedArrayColumn2":["a","b"]},{"moreNestedArrayColumn1":2,"moreNestedArrayColumn2":["c","d"]}],"nestedColumn3":{"moreNestedColumn1":1.0,"moreNestedColumn2":"value"}}} | |
{"column1":"value","column2":[1,2,3,4,5],"column3":{"nestedColumn1":["value1","value2","value3"],"nestedColumn2":[{"moreNestedArrayColumn1":1,"moreNestedArrayColumn2":["a","b"]},{"moreNestedArrayColumn1":2,"moreNestedArrayColumn2":["c","d"]}],"nestedColumn3":{"moreNestedColumn1":1.0,"moreNestedColumn2":"value"}}} | |
{"column1":"value","column2":[1,2,3,4,5],"column3":{"nestedColumn1":["value1","value2","value3"],"nestedColumn2":[{"moreNestedArrayColumn1":1,"moreNestedArrayColumn2":["a","b"]},{"moreNestedArrayColumn1":2,"moreNestedArrayColumn2":["c","d"]}],"nestedColumn3":{"moreNestedColumn1":1.0,"moreNestedColumn2":"value"}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment