Azamat
Azamat

Reputation: 25

How do I save a query as partitioned table in BigQuery?

I have a view in GBQ which has several self-joins. As the data processing cost grows, I want to have more convenient access to the data than using the view that processes a lot of historical data but gives relatively small output.

I want to save output of the view to the table partitioned by day, but can't find a way to do it in web interface of GBQ. Do I need to write a script that processes the data somehow and uploads it back (I'm familiar with Python) or is there a way to do it using BigQuery Web UI?

Upvotes: 1

Views: 960

Answers (1)

Elliott Brossard
Elliott Brossard

Reputation: 33705

You can use a CREATE TABLE statement to create a table from the view. For example,

#standardSQL
CREATE TABLE your_dataset.PartitionedTable
PARTITION BY date_column AS
SELECT * FROM your_dataset.YourView;

This assumes that there is a column in the view definition called date_column that you want to partition by.

Upvotes: 3

Related Questions