title: How can I split BigQuery results into batches of a specific size and save them as multiple CSV files?
body: <p>I have limited experience with BigQuery and recently I have had an issue where I need to provide output in CSV format specifically and I cannot save the results if it is more that 150,000 rows or so as a local csv files.
  I have read about a few solutions using Google Storage but I was wondering if I could write a SQL code in BQ to split my output into batches of no more than 150,000.
  I have used something very simple that works fine for 2-3 batches but is extremely inefficient for larger sizes. Say if I had 1,500,000 and needed 10 batches.</p>
  <pre><code>SELECT *
  FROM output_tbl
  LIMIT 150,000
  
  save the results in a BQ table, temp_tbl1
  
  SELECT *
  FROM output_tbl
  WHERE key_column NOT IN (SELECT DISTINCT key_column FROM temp_tbl1)
  LIMIT 150,000
  
  save the results in another BQ table, temp_tbl2
  
  SELECT *
  FROM output_tbl
  WHERE key_column NOT IN 
                       (SELECT DISTINCT key_column FROM temp_tbl1
                        UNION ALL
                        SELECT DISTINCT key_column FROM temp_tbl2)
  LIMIT 150,000
  </code></pre>
  <p>And continue the process... This is very manual and inefficient. Is there a way to generate all batches at once?</p>