[英]Write query results from a table to a partitioned - clustered table in BigQuery
I have temp table where data is loaded from a cloud storage and a main table which is partitioned by "tdate" and clustered by " serid "我有一个临时表,其中数据是从云存储加载的,还有一个主表,它由“tdate”分区并由“ serid ”聚集
tdate and serid columns exists in temp table and tdate is like this format "YYYY-MM-DD" and serid is integer number tdate和serid列存在于临时表中,tdate 是这样的格式“YYYY-MM-DD”,serid 是 integer 数字
I know how to write query results like below.我知道如何编写如下查询结果。
CREATE TABLE `[project].[dataset].[dest table]`
PARTITION BY tdate
CLUSTER BY serid
AS
SELECT * FROM `[project].[dataset].[table]`;
Can somebody tell me how can i achieve this to append data from temp table to main table using bq command or in python有人能告诉我如何使用bq命令或在python中实现从临时表到主表的 append 数据吗
p:s Im new to gcp and just started today p:s 我是 gcp 的新手,今天才开始
Did you try to use script ?您是否尝试使用脚本? I mean to run several queries in the same call separated by semicolon;我的意思是在用分号分隔的同一个调用中运行多个查询;
CREATE TABLE IF NOT EXISTS `[project].[dataset].[dest table]` (
# Add your schema here
tdate date,
serid numeric
)
PARTITION BY tdate
CLUSTER BY serid;
INSERT INTO `[project].[dataset].[dest table]` SELECT * FROM `[project].[dataset].[table]`;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.