Skip to content
Advertisement

Google Bigquery SQL with clause `where 1=0` is not returning correct schema

I recently added a new column in my BigQuery Table. The following code snippet is used in legacy code to determine the table schema

df = gbq.read_gbq('SELECT * FROM {}.{} where 1=0'.format(BIGQUERY_DATASET_NAME, table), project_id=project_id)

But the problem is that it is not returning the newly added column in the df. Although when I use some other condition like 1=3 in where clause or limit 0 then it returns the correct schema.

Trying to understand what is causing the issue.

Advertisement

Answer

I’m guessing, it has to do with caching , you can always ask BQ not to use caching :

df =  gbq.read_gbq('SELECT * FROM {}.{} where 1=0'.format(...)
     , configuration = {'query': {'useQueryCache': False}} )
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement