I would like to produce a sorted CSV export of a large BigQuery table in Google Cloud Storage. Currently to do this, we start with an unsorted table, then do a SELECT * FROM table ORDER BY col1, col2
into another table, and then export that table to GCS. This works well, since the export seems to use the insertion order of the second table.
However, ORDER BY
has limitations, as discussed here and here. We get the dreaded "Resources exceeded during query execution." error when we try this on a sufficiently large table.
Is there another way to perform this?