Given a JSON input file of
[
{
"text": "text field 1",
"tags": [
"Tag1",
"2nd Tag",
"Last Tag in Array"
]
}
]
I've done the following
copy rma_test.flexdata2 from '/data/tmp/short.json' parser fjsonparser(); - note I did not flatten the array
select compute_flextable_keys_and_build_view('rma_test.flexdata2');
I can see that the data has been loaded correctly.
dbadmin=> select maptostring(__raw__) from rma_test.flexdata2;
maptostring
-------------------------------------------------------------------------------------------------------------
{
"tags":
{
"0": "Tag1",
"1": "2nd Tag",
"2": "Last Tag in Array"
},
"text": "text field 1"
}
(1 row)
How can I create a query that returns just the 2nd tag field (which appears to have an array subscript of 1)?
This what I thought it would be, but it doesn't seem to work. I get a blank row.
dbadmin=> select maplookup(__raw__, 'tags.1') from rma_test.flexdata2;
maplookup
-----------
(1 row)
Obviously, I'm having a basic misunderstanding of how querying nested maps works. Any clarification would be most appreciated.
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.