Alexander Kalitenya
Alexander Kalitenya

Reputation: 43

Can BigQuery View reference other Tables and Views from different datasets/projects?

According to BigQuery Views docs: "Also, views can only reference other tables and views with the same Dataset location."

But in fact i can create a View like this (query is just for example):

SELECT a.body 
FROM [fh-bigquery:reddit_comments.2008] as a
inner JOIN flatten([bigquery-samples:playlists.playlists],tracks.data)
as b ON a.author=b.tracks.data.artist.name

And then reference this view in query like a normal table:

SELECT * FROM [flow-1202:alex_centre.test_v_501] LIMIT 1000

And it works.

Do we have more restrictions when using Views instead of Subqueries in BigQuery?

Upvotes: 4

Views: 2181

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

In the quote you referenced - the key word is "location"!
You cannot reference tables/views from different location in same view See more about Dataset Location here - https://cloud.google.com/bigquery/docs/managing_jobs_datasets_projects#datasets

in the example from your question - both tables are in us location - thus it works!

Upvotes: 3

Related Questions