-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing a sibling's value from a JSON Array in JSONserde #195
Comments
saidatta
changed the title
Accessing a sibling's value from a JSON Array in serde
Accessing a sibling's value from a JSON Array in JSONserde
Aug 23, 2017
I see... I was about to tell you to try with views, but it's not that easy
since you want to pick something in the array.
There are 2 ways you can do something like that, one is to conver
'action'to string and use
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-get_json_object
or to write a generic UDF that takes an array of structs, and outputs the
metric you want.
The SerDe does not do complex mapping, that is better done upstream. The
mapping is meant for those occasions when the naming in json is not
compatible with hive (different rules for case sensitivity, reserved words,
etc).
R.
2017-08-23 11:10 GMT-07:00 Venkata Munnangi <[email protected]>:
… Hey,
*Given*
This is my JSON
...
"actions": [
{
"action_type": "link_click",
"value": "1"
},
{
"action_type": "page_engagement",
"value": "1"
},
{
"action_type": "post_engagement",
"value": "1"
},
.....
]
}
...
I would like to map each action_type's value into a specific column of my
external Table
CREATE EXTERNAL TABLE IF NOT EXISTS raw_marketing_other.facebook_ad_cost_dtl_hrly (
...
linkClick : int
pageEngagement : int
...
)
*Question*
Is this possible in the mapping of serdeProperties? something like this.
WITH serdeproperties(
"mapping.linkClick" = "actions[action_type="link_click].value",
...
*Note*: where actions[action_type="link_click]" is meant to return the
first occurence of json object with that condition?
If it is not possible through custom mappings, then is there any
alternative solution for it?
Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#195>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AA3mtfdEUolKBPTeDs2ltGTg9Sb0Wdwvks5sbGsSgaJpZM4PAYpA>
.
|
Bummer. I can do mapping with nested map attributes, right?
and do
for mapping Do I need to provide any additional flags? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey,
Given
This is my JSON
I would like to map each action_type's value into a specific column of my external Table
For example,
linkClick
column will have the value of 1 derived from that json object.Question
Is this possible in the mapping of serdeProperties? something like this.
Note: where
actions[action_type="link_click]"
is meant to return the first occurence of json object with that condition?If it is not possible through custom mappings, then is there any alternative solution for it?
Thanks
The text was updated successfully, but these errors were encountered: