简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM