Created
March 28, 2012 16:08
-
-
Save s3u/2227815 to your computer and use it in GitHub Desktop.
UDF and JSONPath
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
a1 = [{ | |
"name": "Brand-A", | |
"ns": "df", | |
"aspectValue" : [{ "name": "Gap"}, | |
{"name": "Addidas"}, | |
{"name": "Gravati"}] | |
}, | |
{ | |
"name": "Brand-B", | |
"ns": "df", | |
"aspectValue" : [{ "name": "Gap"},{"name": "Addidas"}] | |
}, | |
{ | |
"name": "Brand-C", | |
"ns": "df", | |
"aspectValue" : [{ "name": "Gravati"},{"name": "Addidas"}] | |
}]; | |
a2 = [{ | |
"name": "Brand-A", | |
"ns": "df", | |
"aspectDetails": [{"name": "Gravati","count": 32}, | |
{"name": "Florsheim by Duckie Brown","count": 18}] | |
}, | |
{ | |
"name": "Brand-C", | |
"ns": "df", | |
"aspectDetails": [{"name": "Gravati","count": 32}, | |
{"name": "Florsheim by Duckie Brown","count": 18}] | |
}]; | |
names = "{a1.aspectValue..name}"; | |
-- Flatten names into a single array using a UDF | |
n = concat(names); | |
r = select a2.name, a2.ns, a2.aspectDetails[?('n.indexOf(@.name) > -1')] from a2 as a2, a1 as a1 where a1.name = a2.name; | |
return r; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment