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