How to get the List of all the partitions from BigQuery partitioned table

When you create table with require_partition_filter = true  in Bigquery, you will have to mention the partition column as part of the filter condition, otherwise the query will fail with the below error message:

Cannot query over table 'mydataset.table_partitiontime' without a filter over \ncolumn(s) '_PARTITION_LOAD_TIME', '_PARTITIONDATE', '_PARTITIONTIME' \nthat can be used for partition elimination
\n\n

Example:

Here's an example table:

\n\n
CREATE TABLE mydataset.tablename\n(\nCol1 INT64 \n)\nPARTITION BY DATE(_PARTITIONTIME)\nOPTIONS(require_partition_filter = true);\n
\n\n

Solution:

In order to find out the list of all the available partitions in a table, you can use the below query:

\n\n
SELECT * FROM `mydataset.tablename$__PARTITIONS_SUMMARY__`\n
\n\n

The bigquery.jobs.create permission is required to run this query

victor

posted on

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds



 Comments are Locked for this post