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\nCREATE TABLE mydataset.tablename\n(\nCol1 INT64 \n)\nPARTITION BY DATE(_PARTITIONTIME)\nOPTIONS(require_partition_filter = true);\n
\n\nSolution:
In order to find out the list of all the available partitions in a table, you can use the below query:
\n\nSELECT * FROM `mydataset.tablename$__PARTITIONS_SUMMARY__`\n
\n\nThe bigquery.jobs.create
permission is required to run this query
victor
posted onEnjoy 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