简体   繁体   English

无法删除分区的 bigquery 表

[英]Can not delete a partitioned bigquery table

I have a partitioned table in bigquery which needs to be unpartitioned.我在 bigquery 中有一个分区表需要取消分区。 It is empty at the moment so I do not need to worry about losing information.目前它是空的,所以我不必担心丢失信息。 I deleted the table by clicking on it > choosing delete > typing delete but the table is still there even I refreshed the page or wait for 30 mins.我通过单击删除了表格 > 选择删除 > 输入删除,但即使我刷新页面或等待 30 分钟,表格仍然存在。

Then I tried the cloud shell terminal:然后我尝试了云shell终端:

bq rm --table project:dataset.table_name

then it asked me to confirm and deleted the table but the table is still there!!!然后它要求我确认并删除该表,但该表仍然存在!!!

Once I want to create an unpartitioned table with the same name, it gives an error that a table with this name already exists!一旦我想创建一个未分区的同名表,它就报错说这个名字的表已经存在!

I have done this many times before, not sure why the table does not get removed?我以前做过很多次,不知道为什么桌子没有被删除?

Deleting partitions from Google Cloud Console is not supported.不支持从 Google Cloud Console 删除分区。 You need to execute the command bq rm with the -t shortcut in the Cloud Shell.您需要在 Cloud Shell 中使用-t快捷方式执行命令bq rm

Before deleting the partitioned table, I suggest verifying you are going to delete the correct tables (partitions).在删除分区表之前,我建议确认您要删除正确的表(分区)。

You can execute these commands:您可以执行这些命令:

for table in `bq ls --max_results=10000000 $MY_DATASET_ID | grep TABLE | grep $MY_PART_TABLE_NAME | awk '{print $1}'`; do echo $MY_DATASET_ID.$table; done

For the variable $MY_PART_TABLE_NAME , you need to write the table name and delete the partition date/value, like in this example "table_name_ 20200818 ".对于变量$MY_PART_TABLE_NAME ,您需要写入表名并删除分区日期/值,如本例中的“table_name_ 20200818 ”。

After verifying that these are the correct partitions, you need to execute this command:验证这些是正确的分区后,您需要执行此命令:

for table in `bq ls --max_results=10000000 $MY_DATASET_ID | grep TABLE | grep $MY_PART_TABLE_NAME | awk '{print $1}'`; do echo $MY_DATASET_ID.$table; bq rm -f -t $MY_DATASET_ID.$table; done

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM