google-bigquery - 如何在 BigQuery 中将分区表复制到另一个分区表

标签 google-bigquery

我正在尝试将一个分区表复制到另一个分区表中。根据docs ,这应该是可能的。

If you want to copy a partitioned table into another partitioned table, the partition specifications for the source and destination tables must match.

为了测试,我创建了两个具有相同架构的分区表(partition1partition2)。我将 3 条记录推送到 partition1 表上的分区 $20170101 中:

echo '{"a":1, "b":2}' | bq insert '<removed>.partition1$20170101'
echo '{"a":1, "b":2}' | bq insert '<removed>.partition1$20170101'
echo '{"a":1, "b":2}' | bq insert '<removed>.partition1$20170101'

看起来不错:

enter image description here

接下来,我将 2 条记录推送到 partition2 表和同一分区 ($20170101):

echo '{"a":1, "b":2}' | bq insert '<removed>.partition2$20170101'
echo '{"a":1, "b":2}' | bq insert '<removed>.partition2$20170101'

再说一遍,这看起来不错:

enter image description here

现在,我想将附加 partition2 复制到 partition1 中。我希望在 $20170101 分区下的 partition1 中看到 5 条记录:

bq cp --append_table <removed>.partition2 <removed>.partition1
Waiting on bqjob_r6d160e17a3b7b733_0000015bb238aa54_1 ... (0s) Current status: DONE   
Tables '<removed>.partition2' successfully copied to '<removed>.partition1'

但是,partition1 中仍然只有 3 条记录。

我做错了什么?

最佳答案

这是我安装的 gcloud 工具版本中的错误。我更新了它,然后它按预期工作了。

运行:

gcloud 组件更新

关于google-bigquery - 如何在 BigQuery 中将分区表复制到另一个分区表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43670695/

相关文章:

google-bigquery - 使用 bigquery 从 GDELT 收集数据

google-bigquery - 如何在 BigQuery 中查询 INFORMATION_SCHEMA.TABLE_STORAGE_TIMELINE_BY_PROJECT

sql - 在 SQL SELECT 中引用其他列

sql - BigQuery重复的栏名称

python - 如何通过 API 为新 View 提供对 BigQuery 数据集的访问权限(补丁)

google-bigquery - Big Query Table Last Modified Timestamp 与上次插入表的时间不对应

python - 如何将查询结果插入 BigQuery 前缀表

google-bigquery - 如何在大查询查询中使用标签来跟踪成本?

SQL - 从多列中分配/减去一列

google-bigquery - 在 BigQuery 中查找模式