Big query nested json strings to arrays then new tables - arrays

Bigquery Database
I've got a webhook that's pushing to my big query table. The problem is it has lots of nested json strings which are brought in as strings. I ultimately want to make each column with these json strings into their own tables but I'm getting stuck because I can't figure out how to get them unnested and into an array.
[{"id":"63bddc8cfe21ec002d26b7f4","description":"General Admission", "src_currency":"USD","src_price":50.0,"src_fee":0.0,"src_commission":1.79,"src_discount":0.0,"applicable_pass_id":null,"seats_label":null,"seats_section_label":null,"seats_parent_type":null,"seats_parent_label":null,"seats_self_type":null,
"seats_self_label":null,"rate_type":"Rate","option_name":null,"price_level_id":null,"src_discount_price":50.0,"rate_id":"636d6d5cea8c6000222c640d","cost_item_id":"63bddc8cfe21ec002d26b7f4"}]
Here's the sample return from the original source and below is a screenshot of what I'm working with.
[Current Database
I've tried a number of things but the multiple nestings and string to array issue are really hampering everything I've tried.
I'm honestly not sure exactly what output/structure is best for this data set. I assume that each of the json returns probably just needs to be its own table and I can reference or join them based off that first "id" value in the json strings but I'm wide open to suggestions.

You can use a combination of JSON functions, and array functions to manipulate this kind of data.
JSON_EXTRACT_ARRAY can convert the JSON formatted string into an array, UNNEST then can make each entry into rows, and finally JSON_EXTRACT_SCALAR can pull out individual columns.
So here's an example of what I think you're trying to accomplish:
with sampledata as (
select """[{"id":"63bddc8cfe21ec002d26b7f4","description":"General Admission", "src_currency":"USD","src_price":50.0,"src_fee":0.0,"src_commission":1.79,"src_discount":0.0,"applicable_pass_id":null,"seats_label":null,"seats_section_label":null,"seats_parent_type":null,"seats_parent_label":null,"seats_self_type":null,"seats_self_label":null,"rate_type":"Rate","option_name":null,"price_level_id":null,"src_discount_price":50.0,"rate_id":"636d6d5cea8c6000222c640d","cost_item_id":"63bddc8cfe21ec002d26b7f4"},{"id":"63bddc8cfe21ec002d26b7f4","description":"General Admission", "src_currency":"USD","src_price":50.0,"src_fee":0.0,"src_commission":1.79,"src_discount":0.0,"applicable_pass_id":null,"seats_label":null,"seats_section_label":null,"seats_parent_type":null,"seats_parent_label":null,"seats_self_type":null,"seats_self_label":null,"rate_type":"Rate","option_name":null,"price_level_id":null,"src_discount_price":50.0,"rate_id":"636d6d5cea8c6000222c640d","cost_item_id":"63bddc8cfe21ec002d26b7f4"}]""" as my_json_string
)
select JSON_EXTRACT_SCALAR(f,'$.id') as id, JSON_EXTRACT_SCALAR(f,'$.rate_type') as rate_type, JSON_EXTRACT_SCALAR(f,'$.cost_item_id') as cost_item_id
from sampledata, UNNEST(JSON_EXTRACT_ARRAY(my_json_string)) as f
Which creates rows with specific columns from that data, like this:

Related

How to transform a list of numbers into seperate elements talend tmap

I have a list of codes for each state as an input stored in a table.
What I want as output is this , using tmap transformations
This is the job I made but it doesn't seem to work correctly like I want. The output should have 1000 rows.
Does anybody know how to solve this?
One way to do this is to convert your list to a string of comma-separated values (using tConvertType for instance) and then use tNormalize to split this string into individual rows.

Azure Data Factory extract JSON column from CSV

I am using ADF to process a csv file which has in one of its columns an array of JSON Documents with same key:value pairs e.g.
Col1| Col2| Col3| Col4
Str1| Str2| Str3| [{"key1":"value1","key2":"value1"},{"key1":"value3","key2":"value4"}]
As you can see, the documents have the same structure and each array could have many documents in it.
I've tried to use the flatten and parse activities but without success. The flatten activity doesn't see it as an array to flatten and having difficulty having the parse give me anything at all.
Any help would be appreciated.

How can I parse JSON arrays in postgresql?

I am using PostgreSQL 9.5.14, and have a column in a table that contains JSON arrays that I need to parse for their contents.
Using a select I can see that the structure of the JSON is of this kind:
SELECT rule_results from table limit 5;
Result:
[{"rule_key":"applicant_not_lived_outside_eu"},{"rule_key":"family_assets_exceed_limit"},{"rule_key":"owned_a_deed"}]
[]
[]
[{"rule_key":"family_category","details":"apply_with_parents_under_25"}]
[]
I have been unable to create an SQL command to give me the values of the rule_key keys.
I've attempted to use the documentation for json-functions in postgresql to find a solution from
https://www.postgresql.org/docs/9.5/functions-json.html
SELECT rule_results::json->'rule_key' as results from table;
This gives me null values only.
SELECT jsonb_object_keys(rule_results::jsonb) from table;
This results in the error msg "cannot call jsonb_object_keys on a scalar", which seems to mean that the query is limited to a single row.
This looks simple enough, an array with key:value pairs, but somehow the answer eludes me. I would appreciate any help.
demo: db<>fiddle
Different solutions are possible. It depends on what you are expecting finally. But all solutions would use the function json_array_elements(). This expands every element into one row. With that you can do whatever you want.
This results in one row per value:
SELECT
value -> 'rule_key'
FROM
data,
json_array_elements(rule_results)

How to update keys in a JSON array Postgresql

I am using PostgreSQL 9.4.1 and have run into an issue with a column that I need to update. The column is of type JSON with elements in the following format:
["a","b","c",...]
["a","c","d",...]
["c","d","e",...]
etc.
so that each element is a string. It is my understanding that each of these elements are considered keys to the JSON array (please correct me if I am a bit confused here, I haven't ever worked with JSON datatype columns before, so I'm still trying to get a grip on them anyways). There is not an actual pattern to these arrays, and their contents are dependent on user input from somewhere else. My goal is to update any of the arrays that contain a particular element (say "b" for the purpose of explaining my question more thoroughly) and replace the content "b" with say "b1". Meaning that:
["a","b","c",...]
would be updated to
["a","b1","c",...]
I have found a few ways listed on this site (I don't currently have the links, but I can find them again if necessary) to update VALUES for a particular KEY, but I haven't found a way mentioned to change the KEY itself. I have already found a way to target the specific rows of interest by doing something similar to:
SELECT *
FROM TableA
WHERE column::json ?| ["b", other string elements of interest]
Any suggestions would be greatly appreciated. Thanks for your help!
So I went ahead and gave that a check (because it looks like it should work, and it's more or less what I ended up doing), but I figured out what I was trying to do! What I got was this:
UPDATE TableA
SET column = REPLACE(column::TEXT,'b','b1')::JSON
WHERE column::JSON ?| ['b']
And now that I think about it, I probably don't even need the last where condition because the replace won't affect anything that doesn't have 'b' in it. But that worked for me, and it looks like yours probably should too! Thanks for the help!
I wanted to rename a specific key for json array column.
I tried and it worked on PostgreSQL 9.4:
UPDATE Your_Table_Name
SET Your_Column_Name = replace(Your_Column_Name::TEXT,'Key_Old_Name','Key_New_Name')::json
WHERE attributes::jsonb ? 'Key_Old_Name'
Basically, solution is to go over the list of json_array_elements, and based on json value using CASE condition replace certain value with other one. After all, need to re-build new json array using array_agg() and to_json() description of aggregate functions in psql is here.
Possible query can be the following:
-- Sample DDL and JSON data
CREATE TABLE jsontest (data JSON);
INSERT INTO jsontest VALUES ('["a","b","c"]'::JSON);
-- QUERY
WITH result AS (
SELECT to_json( -- creating updated json structure
array_agg( -- create array with new element "b1"
CASE WHEN element::TEXT = '"b"' -- here we process array elements to find "b"
THEN to_json('b1'::TEXT)
ELSE element
END)) as new_json
FROM jsontest,json_array_elements(jsontest.data) as element
)
UPDATE jsontest SET data = result.new_json FROM result;

Importing jSON Array into Hive/Hadoop

I'm using the HortonWorks Hadoop Sandbox and I have imported a jSON string into a table, as per this guide however I run into trouble as my string contains an array which is not handled well by json_tuple(). I have tried the expolode() function, but that returns the following error:
"Error occurred executing hive query: OK FAILED: UDFArgumentException explode() takes an array or a map as a parameter"
What does that mean exactly and how can I fix it? Would the problem be with the format of the table? I just followed as per the guide above and created the table with:
CREATE EXTERNAL TABLE games
(
value STRING
)
LOCATION '/user/hue/games'
The value I am trying to explode is an array like this:
[{"gameId":49927894,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":100,"championId":53,"spell1":4,"spell2":14,"level":30,"ipEarned":228,"createDate":1404215396001,"fellowPlayers":[{"summonerId":305443,"teamId":200,"championId":62},{"summonerId":468080,"teamId":100,"championId":23},{"summonerId":356814,"teamId":100,"championId":64},{"summonerId":279828,"teamId":200,"championId":222},{"summonerId":284016,"teamId":100,"championId":112},{"summonerId":222776,"teamId":200,"championId":37},{"summonerId":380226,"teamId":100,"championId":104},{"summonerId":871165,"teamId":200,"championId":238},{"summonerId":443896,"teamId":200,"championId":102}],"stats":{"level":12,"goldEarned":7829,"numDeaths":2,"barracksKilled":1,"minionsKilled":15,"championsKilled":2,"goldSpent":6755,"totalDamageDealt":21181,"totalDamageTaken":10271,"team":100,"win":true,"largestMultiKill":1,"physicalDamageDealtPlayer":8258,"magicDamageDealtPlayer":12390,"physicalDamageTaken":7603,"magicDamageTaken":2215,"timePlayed":1560,"totalHeal":782,"totalUnitsHealed":1,"assists":7,"item0":3069,"item1":3024,"item2":2045,"item3":3117,"item4":3082,"item6":3341,"visionWardsBought":1,"magicDamageDealtToChampions":3193,"physicalDamageDealtToChampions":1144,"totalDamageDealtToChampions":4870,"trueDamageDealtPlayer":532,"trueDamageDealtToChampions":532,"trueDamageTaken":451,"wardKilled":2,"wardPlaced":12,"totalTimeCrowdControlDealt":36}},{"gameId":49921219,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":100,"championId":72,"spell1":4,"spell2":11,"level":30,"ipEarned":71,"createDate":1404210159007,"fellowPlayers":[{"summonerId":323330,"teamId":100,"championId":102},{"summonerId":430227,"teamId":200,"championId":134},{"summonerId":1403590,"teamId":200,"championId":114},{"summonerId":382370,"teamId":100,"championId":99},{"summonerId":445767,"teamId":100,"championId":51},{"summonerId":490295,"teamId":200,"championId":19},{"summonerId":313523,"teamId":100,"championId":4},{"summonerId":308769,"teamId":200,"championId":25},{"summonerId":1591549,"teamId":200,"championId":67}],"stats":{"level":16,"goldEarned":12337,"numDeaths":5,"minionsKilled":60,"championsKilled":4,"goldSpent":11955,"totalDamageDealt":128541,"totalDamageTaken":37539,"killingSprees":1,"largestKillingSpree":2,"team":100,"win":false,"neutralMinionsKilled":84,"largestMultiKill":1,"physicalDamageDealtPlayer":68670,"magicDamageDealtPlayer":40557,"physicalDamageTaken":25561,"magicDamageTaken":8767,"timePlayed":2354,"totalHeal":4024,"totalUnitsHealed":1,"assists":12,"item0":3143,"item1":3102,"item2":2045,"item3":3283,"item4":3207,"item6":3364,"visionWardsBought":2,"magicDamageDealtToChampions":3449,"physicalDamageDealtToChampions":3735,"totalDamageDealtToChampions":7690,"trueDamageDealtPlayer":19313,"trueDamageDealtToChampions":505,"trueDamageTaken":3209,"wardKilled":3,"wardPlaced":5,"neutralMinionsKilledEnemyJungle":7,"neutralMinionsKilledYourJungle":77,"totalTimeCrowdControlDealt":1290}},{"gameId":49846672,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":100,"championId":72,"spell1":4,"spell2":11,"level":30,"ipEarned":92,"createDate":1404137990304,"fellowPlayers":[{"summonerId":390284,"teamId":100,"championId":29},{"summonerId":333970,"teamId":200,"championId":236},{"summonerId":306968,"teamId":200,"championId":157},{"summonerId":275006,"teamId":200,"championId":84},{"summonerId":271369,"teamId":200,"championId":92},{"summonerId":942667,"teamId":100,"championId":68},{"summonerId":475293,"teamId":100,"championId":201},{"summonerId":560185,"teamId":100,"championId":115},{"summonerId":340177,"teamId":200,"championId":54}],"stats":{"level":18,"goldEarned":14683,"numDeaths":3,"barracksKilled":1,"turretsKilled":2,"minionsKilled":33,"championsKilled":10,"goldSpent":13153,"totalDamageDealt":146399,"totalDamageTaken":29156,"doubleKills":1,"killingSprees":1,"largestKillingSpree":9,"team":100,"win":true,"neutralMinionsKilled":86,"largestMultiKill":2,"physicalDamageDealtPlayer":85905,"magicDamageDealtPlayer":42140,"physicalDamageTaken":25170,"magicDamageTaken":2669,"largestCriticalStrike":349,"timePlayed":1932,"totalHeal":4997,"totalUnitsHealed":1,"assists":19,"item0":3143,"item1":3207,"item2":3211,"item3":3078,"item4":3009,"item5":1028,"item6":3340,"visionWardsBought":2,"magicDamageDealtToChampions":4955,"physicalDamageDealtToChampions":6923,"totalDamageDealtToChampions":12270,"trueDamageDealtPlayer":18353,"trueDamageDealtToChampions":391,"trueDamageTaken":1317,"wardKilled":3,"wardPlaced":7,"neutralMinionsKilledEnemyJungle":6,"neutralMinionsKilledYourJungle":80,"totalTimeCrowdControlDealt":879}},{"gameId":49842237,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":200,"championId":72,"spell1":4,"spell2":11,"level":30,"ipEarned":239,"createDate":1404132909924,"fellowPlayers":[{"summonerId":1201246,"teamId":100,"championId":18},{"summonerId":306670,"teamId":200,"championId":412},{"summonerId":1424602,"teamId":100,"championId":32},{"summonerId":331359,"teamId":100,"championId":134},{"summonerId":775098,"teamId":200,"championId":10},{"summonerId":309637,"teamId":200,"championId":67},{"summonerId":1111164,"teamId":100,"championId":161},{"summonerId":352500,"teamId":200,"championId":76},{"summonerId":627990,"teamId":100,"championId":13}],"stats":{"level":16,"goldEarned":11745,"numDeaths":1,"turretsKilled":3,"minionsKilled":20,"championsKilled":3,"goldSpent":9790,"totalDamageDealt":119585,"totalDamageTaken":24242,"killingSprees":1,"largestKillingSpree":3,"team":200,"win":true,"neutralMinionsKilled":79,"largestMultiKill":1,"physicalDamageDealtPlayer":64908,"magicDamageDealtPlayer":36298,"physicalDamageTaken":16213,"magicDamageTaken":6611,"timePlayed":1880,"totalHeal":4364,"totalUnitsHealed":1,"assists":12,"item0":3207,"item1":3102,"item2":3068,"item3":3009,"item4":1029,"item5":1027,"item6":3341,"visionWardsBought":2,"magicDamageDealtToChampions":2429,"physicalDamageDealtToChampions":2137,"totalDamageDealtToChampions":4760,"trueDamageDealtPlayer":18378,"trueDamageDealtToChampions":194,"trueDamageTaken":1416,"wardKilled":3,"wardPlaced":9,"neutralMinionsKilledEnemyJungle":9,"neutralMinionsKilledYourJungle":70,"totalTimeCrowdControlDealt":801}},{"gameId":49694129,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":200,"championId":19,"spell1":4,"spell2":11,"level":30,"ipEarned":54,"createDate":1404050008933,"fellowPlayers":[{"summonerId":791058,"teamId":100,"championId":104},{"summonerId":441236,"teamId":200,"championId":115},{"summonerId":469417,"teamId":100,"championId":89},{"summonerId":347644,"teamId":200,"championId":102},{"summonerId":1874556,"teamId":100,"championId":75},{"summonerId":342971,"teamId":200,"championId":25},{"summonerId":359199,"teamId":100,"championId":254},{"summonerId":342453,"teamId":200,"championId":81},{"summonerId":381059,"teamId":100,"championId":38}],"stats":{"level":13,"goldEarned":7193,"numDeaths":5,"minionsKilled":19,"championsKilled":1,"goldSpent":6335,"totalDamageDealt":98517,"totalDamageTaken":26415,"team":200,"win":false,"neutralMinionsKilled":75,"largestMultiKill":1,"physicalDamageDealtPlayer":45035,"magicDamageDealtPlayer":41134,"physicalDamageTaken":21640,"magicDamageTaken":4166,"timePlayed":1622,"totalHeal":12341,"totalUnitsHealed":1,"assists":6,"item0":3153,"item1":3111,"item2":3160,"item6":3340,"visionWardsBought":1,"magicDamageDealtToChampions":4864,"physicalDamageDealtToChampions":1146,"totalDamageDealtToChampions":6355,"trueDamageDealtPlayer":12348,"trueDamageDealtToChampions":344,"trueDamageTaken":608,"wardPlaced":11,"neutralMinionsKilledEnemyJungle":6,"neutralMinionsKilledYourJungle":69,"totalTimeCrowdControlDealt":478}},{"gameId":49679487,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":100,"championId":19,"spell1":4,"spell2":11,"level":30,"ipEarned":103,"createDate":1404045076287,"fellowPlayers":[{"summonerId":368843,"teamId":100,"championId":53},{"summonerId":1850211,"teamId":200,"championId":59},{"summonerId":364524,"teamId":100,"championId":51},{"summonerId":919576,"teamId":200,"championId":89},{"summonerId":280244,"teamId":100,"championId":238},{"summonerId":448125,"teamId":200,"championId":23},{"summonerId":990233,"teamId":200,"championId":63},{"summonerId":551468,"teamId":100,"championId":82},{"summonerId":620390,"teamId":200,"championId":81}],"stats":{"level":18,"goldEarned":16567,"numDeaths":4,"barracksKilled":1,"turretsKilled":2,"minionsKilled":51,"championsKilled":10,"goldSpent":14820,"totalDamageDealt":251883,"totalDamageTaken":46042,"doubleKills":1,"killingSprees":3,"largestKillingSpree":4,"team":100,"win":true,"neutralMinionsKilled":139,"largestMultiKill":2,"physicalDamageDealtPlayer":115795,"magicDamageDealtPlayer":117678,"physicalDamageTaken":33706,"magicDamageTaken":10046,"timePlayed":2273,"totalHeal":25918,"totalUnitsHealed":1,"assists":10,"item0":3153,"item1":3143,"item2":3160,"item3":3284,"item4":3091,"item5":3075,"item6":3364,"visionWardsBought":1,"magicDamageDealtToChampions":16479,"physicalDamageDealtToChampions":9121,"totalDamageDealtToChampions":26052,"trueDamageDealtPlayer":18409,"trueDamageDealtToChampions":451,"trueDamageTaken":2289,"wardKilled":2,"wardPlaced":7,"neutralMinionsKilledEnemyJungle":18,"neutralMinionsKilledYourJungle":121,"totalTimeCrowdControlDealt":1008}},{"gameId":49643142,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":100,"championId":19,"spell1":4,"spell2":11,"level":30,"ipEarned":253,"createDate":1404024693523,"fellowPlayers":[{"summonerId":460616,"teamId":100,"championId":81},{"summonerId":559939,"teamId":100,"championId":79},{"summonerId":1030746,"teamId":200,"championId":236},{"summonerId":421450,"teamId":200,"championId":62},{"summonerId":321477,"teamId":100,"championId":7},{"summonerId":276152,"teamId":100,"championId":92},{"summonerId":1292269,"teamId":200,"championId":63},{"summonerId":561631,"teamId":200,"championId":29},{"summonerId":465045,"teamId":200,"championId":59}],"stats":{"level":18,"goldEarned":16790,"numDeaths":5,"barracksKilled":3,"turretsKilled":3,"minionsKilled":105,"championsKilled":12,"goldSpent":18050,"totalDamageDealt":250227,"totalDamageTaken":54929,"killingSprees":2,"largestKillingSpree":8,"team":100,"win":true,"neutralMinionsKilled":99,"largestMultiKill":1,"physicalDamageDealtPlayer":117959,"magicDamageDealtPlayer":113778,"physicalDamageTaken":45163,"magicDamageTaken":7668,"timePlayed":2261,"totalHeal":34014,"totalUnitsHealed":1,"assists":10,"item0":3153,"item1":3091,"item2":3160,"item3":3274,"item4":3124,"item5":3065,"item6":3340,"magicDamageDealtToChampions":13747,"physicalDamageDealtToChampions":5524,"totalDamageDealtToChampions":19995,"trueDamageDealtPlayer":18488,"trueDamageDealtToChampions":724,"trueDamageTaken":2097,"wardPlaced":5,"neutralMinionsKilledEnemyJungle":26,"neutralMinionsKilledYourJungle":73,"totalTimeCrowdControlDealt":1183}},{"gameId":49459840,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":200,"championId":72,"spell1":4,"spell2":11,"level":30,"ipEarned":113,"createDate":1403929077578,"fellowPlayers":[{"summonerId":674416,"teamId":100,"championId":67},{"summonerId":1600182,"teamId":100,"championId":105},{"summonerId":481511,"teamId":200,"championId":13},{"summonerId":790397,"teamId":100,"championId":412},{"summonerId":1020148,"teamId":200,"championId":53},{"summonerId":651548,"teamId":100,"championId":76},{"summonerId":401190,"teamId":100,"championId":62},{"summonerId":553639,"teamId":200,"championId":51},{"summonerId":1142091,"teamId":200,"championId":115}],"stats":{"level":18,"goldEarned":15974,"numDeaths":4,"turretsKilled":2,"minionsKilled":70,"championsKilled":9,"goldSpent":14048,"totalDamageDealt":165162,"totalDamageTaken":36304,"doubleKills":1,"killingSprees":1,"largestKillingSpree":8,"team":200,"win":true,"neutralMinionsKilled":88,"largestMultiKill":2,"physicalDamageDealtPlayer":94125,"magicDamageDealtPlayer":48323,"physicalDamageTaken":26136,"magicDamageTaken":7798,"largestCriticalStrike":613,"timePlayed":2497,"totalHeal":4294,"totalUnitsHealed":1,"assists":15,"item0":3283,"item1":3102,"item2":3075,"item3":3207,"item4":3078,"item5":1057,"item6":3364,"visionWardsBought":2,"magicDamageDealtToChampions":7822,"physicalDamageDealtToChampions":12309,"totalDamageDealtToChampions":21568,"trueDamageDealtPlayer":22712,"trueDamageDealtToChampions":1436,"trueDamageTaken":2369,"wardKilled":5,"wardPlaced":5,"neutralMinionsKilledEnemyJungle":5,"neutralMinionsKilledYourJungle":83,"totalTimeCrowdControlDealt":899}},{"gameId":49460256,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":100,"championId":72,"spell1":4,"spell2":11,"level":30,"ipEarned":244,"createDate":1403925869628,"fellowPlayers":[{"summonerId":563206,"teamId":200,"championId":11},{"summonerId":582721,"teamId":200,"championId":13},{"summonerId":279571,"teamId":100,"championId":61},{"summonerId":449166,"teamId":200,"championId":4},{"summonerId":276810,"teamId":200,"championId":67},{"summonerId":628613,"teamId":100,"championId":412},{"summonerId":403086,"teamId":100,"championId":23},{"summonerId":860284,"teamId":100,"championId":222},{"summonerId":458717,"teamId":200,"championId":201}],"stats":{"level":16,"goldEarned":10708,"numDeaths":4,"minionsKilled":44,"championsKilled":4,"goldSpent":9738,"totalDamageDealt":113355,"totalDamageTaken":25334,"killingSprees":1,"largestKillingSpree":2,"team":100,"win":true,"neutralMinionsKilled":65,"largestMultiKill":1,"physicalDamageDealtPlayer":62145,"magicDamageDealtPlayer":36007,"physicalDamageTaken":15132,"magicDamageTaken":9118,"largestCriticalStrike":262,"timePlayed":1984,"totalHeal":3256,"totalUnitsHealed":1,"assists":10,"item0":3207,"item1":3283,"item2":1011,"item3":3078,"item4":3082,"item6":3340,"sightWardsBought":1,"visionWardsBought":1,"magicDamageDealtToChampions":5033,"physicalDamageDealtToChampions":6708,"totalDamageDealtToChampions":12367,"trueDamageDealtPlayer":15202,"trueDamageDealtToChampions":626,"trueDamageTaken":1084,"wardKilled":1,"wardPlaced":6,"neutralMinionsKilledEnemyJungle":4,"neutralMinionsKilledYourJungle":61,"totalTimeCrowdControlDealt":678}},{"gameId":49453199,"invalid":false,"gameMode":"CLASSIC","gameType":"MATCHED_GAME","subType":"RANKED_SOLO_5x5","mapId":1,"teamId":200,"championId":58,"spell1":4,"spell2":14,"level":30,"ipEarned":71,"createDate":1403919131778,"fellowPlayers":[{"summonerId":592234,"teamId":100,"championId":80},{"summonerId":394103,"teamId":200,"championId":119},{"summonerId":790397,"teamId":100,"championId":412},{"summonerId":651548,"teamId":100,"championId":236},{"summonerId":707290,"teamId":200,"championId":40},{"summonerId":468391,"teamId":200,"championId":59},{"summonerId":347220,"teamId":200,"championId":84},{"summonerId":272606,"teamId":100,"championId":105},{"summonerId":509766,"teamId":100,"championId":77}],"stats":{"level":18,"goldEarned":12506,"numDeaths":9,"turretsKilled":1,"minionsKilled":234,"championsKilled":5,"goldSpent":12185,"totalDamageDealt":152192,"totalDamageTaken":42303,"team":200,"win":false,"neutralMinionsKilled":11,"largestMultiKill":1,"physicalDamageDealtPlayer":142022,"magicDamageDealtPlayer":8822,"physicalDamageTaken":30981,"magicDamageTaken":10296,"timePlayed":2340,"totalHeal":3935,"totalUnitsHealed":1,"assists":7,"item0":3074,"item1":3143,"item2":3102,"item3":1055,"item4":1054,"item5":3047,"item6":3361,"sightWardsBought":3,"visionWardsBought":1,"magicDamageDealtToChampions":3116,"physicalDamageDealtToChampions":17951,"totalDamageDealtToChampions":22415,"trueDamageDealtPlayer":1348,"trueDamageDealtToChampions":1348,"trueDamageTaken":1026,"wardKilled":1,"wardPlaced":9,"neutralMinionsKilledEnemyJungle":2,"neutralMinionsKilledYourJungle":9,"totalTimeCrowdControlDealt":200}}]
Any help very much appreciated!
The explode() hive function takes a hive array or map, and you gave it a String value. json_tuple() worked in the guide because it made your string into a map.
You'll want to convert your json array into a format that hive can accept, or use one of the JSON SerDes or something of that nature in order to query the way you want.
JSON SerDe for Hive that supports JSON arrays

Resources