Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save a view in BigQuery - Standard SQL Dialect

I am trying to save a view using BigQuery's WebUI, which was created in Standard SQL Dialect, but I am getting this error:

Failed to save view. Bad table reference "myDataset.myTable"; table references in standard SQL views require explicit project IDs

Why is this error showing up? How can I fix it? Should the "Table ID" field of the "Save view" dialog include the project id? Or does this error appear because of the query itself? Just in case, the query is running without any problems.

BigQuery's Save View

Thanks for your help.

like image 964
Milton Avatar asked Mar 28 '17 20:03

Milton


People also ask

How do I save a view in BigQuery?

BigQuery Create View Setup: Using the BigQuery ConsoleWhile choosing the “Project Name”, select a project to store the view. In “Dataset Name”, select a dataset to store the view. Finally, for “Table Name”, mention the name of the view. Click on “Save”.

What dialect of SQL does BigQuery use?

BigQuery supports the Google Standard SQL dialect, but a legacy SQL dialect is also available. If you are new to BigQuery, you should use Google Standard SQL as it supports the broadest range of functionality. For example, features such as DDL and DML statements are only supported using Google Standard SQL.

How do I save a table in BigQuery?

Open the BigQuery page in the Google Cloud console. In the Explorer panel, expand your project and dataset, then select the table. In the details panel, click Export and select Export to Cloud Storage.


2 Answers

Your view has reference to myDataset.myTable - which is ok when you just run it as a query (for example in Web UI).

But to save it as a view you must fully qualify that reference as below

myProject.myDataset.myTable   

So, just add project to that reference

like image 191
Mikhail Berlyant Avatar answered Oct 23 '22 03:10

Mikhail Berlyant


Same reply, in other words

The issue is in this part of query: FROM com.table

When running query, it's fine to not fully specify the name of table like this:

com_company_app_beta_IOS.app_events_20180619

But to save the query as a view the FROM has to be like this:

`company-prod`.com_company_app_beta_IOS.app_events_20180619

You need the backticks around the `company-prod` because the - dash character is unsupported in object names.

The structure in BigQuery look like this: bigquery ui

like image 42
usrbowe Avatar answered Oct 23 '22 01:10

usrbowe