DataDives
DataDives

Reputation: 149

Output nested results in BigQuery

I am curious, is it possible to output nested results?

For example, lets say I have 3 fields:

Date, Name_1, Name_2

Can I nest Name_1 and Name_2 within Date, grouping by date in the output?

If date is the same for multiple output rows, can you group associated fields for the same date together, only showing one unique date but multiple nested fields?

I hope this made sense.

Thanks.

Upvotes: 2

Views: 971

Answers (1)

shollyman
shollyman

Reputation: 4384

Depending on your needs, the NEST() function, or the flattenResults configuration option in the API documentation may be what you need. However, its worth noting that both together don't work together at present: see this answer from one of the BigQuery engineers for more background.

Additionally, if you're using the web UI, the flattenResults option is presented in the "show options" button when composing a query, and via the --flatten_results flag in the CLI.

Upvotes: 2

Related Questions