from Pavans answer: Note that this approach will charge you the cost of scanning the source table for the query as many times as you request it.
from Pentium10 comments: So, suppose I have several years of data, I need to prepare different requests for each day and run it all, and suppose that I have 1000 days in history, I need to pay 1000 times the total price of the request table source?
As we can see, the main problem here is that you perform a full scan every day. The rest of the problem is not a problem and can be easily recorded in any client of your choice
So below - How to split a table avoiding a full table scan every day?
Below, step by step, the approach is shown.
Enough common to spread / apply to any real use case - in the meantime I use bigquery-public-data.noaa_gsod.gsod2017 and I limit the βexerciseβ to only 10 days to keep it readable
Step 1 - Create a Pivot Table
In this step, we a) compress the contents of each row into a record / array
and
b) put them in the appropriate "daily" column
Run the above request in the web interface using pivot_table (or any other name) as the destination
As we can see - here we get a table with 10 columns - one column for one day, and the layout of each column is a copy of the layout of the original table:

Step 2 - processing partitions one by one ONLY scanning the corresponding column (without a full table scan) - pasting into the corresponding section
Run a query from the web user interface with a destination table named mytable $ 20160101
You can run it the next day.
You should now have a destination table like mytable $ 20160102, etc.

You should be able to automate / script this step with any client of your choice.
There are many options for how you can use the above approach - it depends on your creativity.
Note. BigQuery allows up to 10,000 columns in a table, so 365 columns for the corresponding days of the year are definitely not a problem: o) If there is no restriction on how far back you can go with new sections - I heard (but I haven't opportunity to check), now no more than 90 days ago
Refresh
Please note: In the above version there is a small additional logic for packing all aggregated cells into the maximum possible number of final numbers.
ROW_NUMBER() OVER(PARTITION BY d) AS line
and then GROUP BY line
along with ARRAY_CONCAT_AGG(β¦)
doing this
This works well when the row size in the source table is not so large, so the final mixed row size will still be within the row size that BigQuery has (which, in my opinion, is 10 MB at the moment)
If your source table already has a row size close to this limit, use the adjusted version below
In this version, the grouping is deleted so that each row has only a value for one column
As you can see now - the pivot table (sparce_pivot_table) is quite sparse (the same 21.5 MB, but now 114 089 rows versus 11 584 rows in pivot_table), so it has an average row size of 190V versus 1.9 KB in the initial version. This is obviously about 10 times less than the number of columns in the example.
Therefore, before using this approach, it is necessary to do some math to evaluate / evaluate what and how can be done!

However: each cell in the pivot table is a JSON representation of the entire row in the source table. It is such that it contains not only the values ββas for the rows in the source table, but also has a schema in it

As such, it is rather verbose - thus, the cell size can be several times larger than the original size [which limits the use of this approach ... unless you get even more creative: o) ... which still has a lot of areas here to apply: o)]