google cloud platform – Can I manually adjust _PARTITIONTIME for historical data ingestion in BigQuery?
Duplicate of Big Query specify _PARTITIONTIME when inserting from one table into another
Partition in BigQuery can be updated. Google Documentation
Say for eg, I want to change the Partition to Monthly
CREATE TABLE IF NOT EXISTS `schema.data_monthly`
(
name STRING,
id STRING,
publish_time TIMESTAMP
)
PARTITION BY DATE_TRUNC(_PARTITIONTIME, MONTH);
INSERT INTO schema.data_monthly (_PARTITIONTIME, name, id, publish_time)
SELECT DATE_TRUNC(_PARTITIONTIME, MONTH), name, id, publish_time
FROM schema.daily_data;
Now the partitions would be changed. Also If I try to give a wrong DATE_TRUNC function over WEEK, Big Query Will Error
INSERT INTO els_weather.pub_sub_weather_data_monthly (_PARTITIONTIME, name, id, publish_time)
SELECT DATE_TRUNC(_PARTITIONTIME, WEEK), subscription_name, message_id, publish_time
FROM els_weather.pub_sub_weather_data
❗ Timestamp pseudo column for partitioned table only supports MONTH (in UTC timezone) granularity values
Read more here: Source link
