Write from a query to table in BigQuery only if query is not empty
<p>In BigQuery it's possible to write to a new table the results of a query. I'd like the table to be created only whenever the query returns at least one row. Basically I don't want to end up creating empty table. I can't find an option to do that. (I am using the Python library, but I suppose the same applies to the raw API)</p>

<p>Since you have to specify the destination on the query definition and you don't know what it will return when you run it can you tack a <code>LIMIT 1</code> to the end?</p>

<p>You can check the row number in the <a href="https://developers.google.com/resources/api-libraries/documentation/bigquery/v2/python/latest/bigquery_v2.jobs.html#query" rel="nofollow">job result object</a> and then re run the query without the limiter if there are results into your new table.</p>

python google-bigquery