Skip to content
Advertisement

Select query to group records in output json using BigQuery

I have a datetime partitioned table in BigQuery with a schema like:

So, if I do a SELECT * FROMmy_table`, it will generate a JSON with a structure like:

And that format works well in most of my use cases, except for one.

So, if I wanted the id’s of all the inverters i would do

But I also need the timestamps grouped by inverter, but if I do, let’s say, a nested query for getting the timestamps by id, like:

then the resulting json would be:

Now, that was a long introduction.

The question is: Is there a way of querying the data so the result of the query looks something like the following?

Advertisement

Answer

Is this what you want?

You say that SELECT * returns JSON. I think this is a function of your API. When you use the BigQuery API, you don’t see JSON.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement