Hi all,
I have a a simple schema that I want to store as JSON. So I've written a
simple JsonStorage class but it requires that the tuple's first field is a
map. The problem is in converting a regular tuple into a map:
DESCRIBE thing;
> thing: {id: chararray,field1: chararray,field2: chararray}
What the map/JSON should look like:
{ 'id': 'id0', 'foo': 'valueFromField1', 'bar': 'valueFromField2' }
So this should work but seems to be invalid syntax:
jsonStore = FOREACH thing GENERATE
[ 'id'#id, 'foo'#field1, 'bar'#field2 ] AS json:map[];
ERROR 1000: Error during parsing. Encountered " "[" "[ "" at line 150,
column 23.
Was expecting one of:
"flatten" ...
"(" ...
"-" ...
"(" ...
"(" ...
"(" ...
"(" ...
"(" ...
The only way I have this syntax working is if I use only constants in the
map:
jsonStore = FOREACH thing GENERATE
[ 'id'#'const', 'foo'#'const', 'bar'#'const' ] AS json:map[];
Is it possible to do what I'm thinking?
Thanks,
Josh