BigQuery Date-Partitioned Views

前端 未结 2 1731
悲&欢浪女
悲&欢浪女 2020-12-03 10:30

BigQuery allows you to create date-partitioned tables: https://cloud.google.com/bigquery/docs/creating-partitioned-tables

I\'d like to be able to create views on top

相关标签:
2条回答
  • 2020-12-03 11:14

    For anyone trying to do this with a wildcard partition date table such as Firebase or Google Analytics:

    create view some.view as ( 
        select *, _TABLE_SUFFIX as suffix from 
        `firebase-public-project.analytics_153293282.events_*` 
    )
    
    
     select * from some.view WHERE suffix = '20180814'
    
    0 讨论(0)
  • 2020-12-03 11:18

    Define your view to expose the partitioning pseudocolumn, like this:

    SELECT *, EXTRACT(DATE FROM _PARTITIONTIME) AS date
    FROM Date partitioned table;
    

    Now if you query the view using a filter on date, it will restrict the partitions that are read.

    0 讨论(0)
提交回复
热议问题