from google.cloud import bigquery
bigquery_client = bigquery.Client(project="my-project")
dataset = bigquery_client.dataset("my-dataset")
table = dataset.table("v_test")
#Fails on Standard SQL
#table._properties['view'] = {'query': "select * from `my-project.my.dataset.test_table`",'useLegacySql':False}
#Works on Legacy SQL
table._properties['view'] = {'query': "select * from [my-project:my-dataset.test_table]",'useLegacySql':True}
try:
table.create()
except Exception as err:
print(err)
The https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/bigquery/google/cloud/bigquery/table.py#L355 should also take in another property for useLegacySql
Example payload at http://stackoverflow.com/questions/33243427/how-can-i-create-a-new-view-in-bigquery-using-the-python-api
The https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/bigquery/google/cloud/bigquery/table.py#L355 should also take in another property for useLegacySql
Example payload at http://stackoverflow.com/questions/33243427/how-can-i-create-a-new-view-in-bigquery-using-the-python-api