Elasticsearch Arrays are not supported in superset (SQL API) - arrays

When I try to run the Query in superset which contain elastic search Array values I am getting following error -
elasticsearch error: TransportError(500, 'ql_illegal_argument_exception', 'Arrays (returned by [decision.certification.comments.user.sn]) are not supported')
My Query is : SELECT "column_1" from "table_1";
where column_1 contains the Array Values and I am trying to get those values into the table form in superset but Array Values are not getting populated.

This is a known limitation of the Superset elasticsearch-dbapi driver. ElasticSearch documentation for their own SQL API explains the reason for this:
Array fields are not supported due to the "invisible" way in which
Elasticsearch handles an array of values: the mapping doesn’t indicate
whether a field is an array (has multiple values) or not, so without
reading all the data, Elasticsearch SQL cannot know whether a field is
a single or multi value.

Related

Azure Data Factory Array of Strings mapped in Copy Activity, Cosmos SQL sink only accepts string and not array of strings?

I have an Azure Data Factory Pipeline with a Copy Activity. Source is a JSON file (some generated pipeline variables too) and Sink is a Cosmos SQL Collection. Before Mapping I imported the schema and a particular field from the sink collection has been identified to be of type array [] with string elements.
The problem however is that this field mapping now only accepts a STRING and not an Array of strings. I am not sure if this a bug with ADF or something to do with how I genrated the source variable for this mapping.
If the source variable accessGroups is of string the copy works fine(it shouldn't though right???). However if I substitute this with a variable containing an array of strings I get the following error:
Failed to convert the value in 'value' property to 'System.String' type. Please make sure the payload structure and value are correct. Object must implement IConvertible.
Just to be clear, I am mapping the source variable accessGroups to ['accessGroups'] and not ['accessGroups'][0]. Besides ADF does not allow mapping source variables to individual array elements anyway.
Any one faced this issue before or aware of any workaround?

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)

Postgres: is there any row_to_json equivalent that returns values only?

In a project I'm working on, I need to stream potentially large data sets from a Postgres database to the client, for analytics purposes.
The application is built in Rails (irrelevant for this question) and after a bit of research I'm currently able to stream query results by using COPY in Postgres:
COPY (SELECT row_to_json(t) from (#{query}) t) TO STDOUT;
Sources (for who's interested):
https://shift.infinite.red/fast-csv-report-generation-with-postgres-in-rails-d444d9b915ab
https://github.com/brianhempel/stream_json_demo
This works, but it yields every row as a key-value pair, e.g.:
["{\"id\":403457,\"email\":\"email403457#example.com\",\"first_name\":\"Firstname403457\",\"last_name\":\"Lastname403457\",\"source\":\"adwords\",\"created_at\":\"2015-08-05T22:43:07.295796\",\"updated_at\":\"2017-01-19T04:48:29.464051\"}"]
In the spirit of minimising the size (in bytes) of the response and especially since this is getting served through the web, I want to return just an array of values for every row, i.e.:
["[403457, \"email403457#example.com\", \"Firstname403457\", \"Lastname403457\", \"adwords\", \"2015-08-05T22:43:07.295796\", \"2017-01-19T04:48:29.464051\"]"]
Is there a way to achieve this within Postgres, even by nesting functions, starting from the query above?
You could create a simple SQL function that converts a row into the desired format:
CREATE FUNCTION row2json(anyelement) RETURNS json
LANGUAGE sql STABLE AS
'SELECT json_agg(z.value) FROM json_each(row_to_json($1)) z';
Then you use that to transform the output:
SELECT row2json(mytab) FROM mytab;
If performance is more important than JSON output, just cast the result to a string:
SELECT CAST(mytab AS text) FROM mytab;

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

Search Arrays in Hive

I need to search an array function for specific values in hive.
I have a table that creates a row for each event. I used collect_set(event_id) to roll the table up to the person level. I now need to search the array to put users into separate categories. I tried using a case when statement, find_in_set, and in_file but none of those functions work on arrays.
Any ideas? Can I convert an array into a string? Ideally I would have used a group_concat function in SQL - but hive does not support it
ARRAY_CONTAINS(events, search_param) will return a Boolean if search_param is found in the events array.
It's available in Hive 0.7.1, and possibly earlier versions.

Resources