Reputation: 460
I was planning to create a bigquery javascript udf to parse json (as json functions are still in preview phase). Now, if I write a function, then a return type has to be specified. For example: If my json function has to return an array of records, then the return type looks like the following in function declaration:
create temp function de_serialize_json(json_string string)
returns array<struct<id string, points float64, description string, long_description string>>
language js as r"""
return JSON.parse(json_string)
"""
;
Is there a way to generalize the return data structure? Meaning, I can input json of any structure and the output can be obtained w/o changing the return structure.
Please let me know.
Upvotes: -1
Views: 502
Reputation: 1475
As per your requirement, you can try the feature by filling the enrollment form. Right now, the way you are trying to achieve this is the way available since BigQuery has a fixed structure to convert JSON to struct. If you want to use the JSON data then you have to wait until it is available in GA since there is no generic return data structure available.
Upvotes: 0