Skip to content

The Python BigQuery client fails on creating a view in standardSQL  #3388

@hm98765

Description

@hm98765
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

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.backendtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions