'How to query legacy SQL table in Google Sheets

I'm trying to fill a Google Sheet with data from a legacy SQL table in Big Query. When I go to data -> data connectors, find the table and try to load it, I receive the error; BigQuery error: Cannot reference a legacy SQL view in a standard SQL query.

Not surprising, so I try to modify the query to make sure it's written in legacy SQL.

#legacySQL
SELECT *
FROM [wihp.ps_order_id]

However when I do so, I get another error; BigQuery error: Query text specifies use_legacy_sql:true, while API options specify:false. It could be caused by client libraries having different default dialects, see examples at https://cloud.google.com/bigquery/docs/pandas-gbq-migration#standard-sql-query

So it seems that Google Sheets is using pandas in the backend, and although I can use the #legacySQL to specify that I want to use legacy SQL in the query text, I'm not sure how I can get at the backend to change dialect='legacy' in the call to pd.read_gbq(). Does anyone know how to do this, so that I can populate my Google Sheets with data from a Legacy SQL table?

Thanks!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source