Databricks – 无法创建表,关联的位置不为空且不是 Delta 表

huangapple go评论59阅读模式
英文:

Databricks -Cannot create table The associated location is not empty and also not a Delta table

问题

我遇到了以下错误:

> 无法创建表('hive_metastore.MY_SCHEMA.MY_TABLE')。关联的位置
> ('dbfs:/user/hive/warehouse/my_schema.db/my_table')不为空,而且
> 也不是Delta表。

我尝试通过运行以下命令来解决这个问题:

drop table 'hive_metastore`.`MY_SCHEMA`.`MY_TABLE`

但然后我遇到了以下错误:

> [TABLE_OR_VIEW_NOT_FOUND] 无法找到表或视图
> 'hive_metastore.MY_SCHEMA.MY_TABLE'。请验证
> 模式和目录的拼写和正确性。

我该如何克服这个问题并在该位置重新创建具有相同名称的表呢?
我已经尝试过create or *replace* table,但仍然出现原始错误位置不为空

英文:

I am getting the error:

> Cannot create table ('hive_metastore.MY_SCHEMA.MY_TABLE'). The
> associated location
> ('dbfs:/user/hive/warehouse/my_schema.db/my_table') is not empty and
> also not a Delta table.

I tried to overcome this by running

drop table 'hive_metastore`.`MY_SCHEMA`.`MY_TABLE`

But then I am getting

> [TABLE_OR_VIEW_NOT_FOUND] The table or view
> hive_metastore.MY_SCHEMA.MY_TABLE cannot be found. Verify the
> spelling and correctness of the schema and catalog.

How Can I overcome that and recreate the table the that name in that location?
I already tried create of *replace* table but still getting the original error
location is not empty

答案1

得分: 1

如果表存在,您可以使用以下命令删除它:

DROP TABLE IF EXISTS hive_metastore.MY_SCHEMA.MY_TABLE;

如果表不存在,您可以使用以下命令创建它:

CREATE TABLE hive_metastore.MY_SCHEMA.MY_TABLE (<列定义>) USING DELTA LOCATION 'dbfs:/user/hive/warehouse/my_schema.db/my_table';

如果仍然遇到相同的错误,您可以使用以下命令删除与表关联的位置的内容:

dbutils.fs.rm('dbfs:/user/hive/warehouse/my_schema.db/my_table', True)

在删除位置的内容后,您可以尝试再次使用上述命令创建表。

请参考以下链接以获取更多信息:

https://stackoverflow.com/questions/69551620/databricks-is-not-empty-but-its-not-a-delta-table

https://community.databricks.com/t5/data-engineering/error-the-associated-location-is-not-empty-but-it-s-not-a-delta/m-p/7430#M3314

英文:

If the table exists, you can drop it using the following command:

DROP TABLE IF EXISTS hive_metastore.MY_SCHEMA.MY_TABLE;

If the table does not exist, you can create it using the following command:

CREATE TABLE hive_metastore.MY_SCHEMA.MY_TABLE (<column definitions>) USING DELTA LOCATION 'dbfs:/user/hive/warehouse/my_schema.db/my_table';

If you still get the same error, you can delete the contents of the location associated with the table using the following command:

dbutils.fs.rm('dbfs:/user/hive/warehouse/my_schema.db/my_table', True)

After deleting the contents of the location, you can try to create the table again using the above command.

Please see the below threads for your reference.

https://stackoverflow.com/questions/69551620/databricks-is-not-empty-but-its-not-a-delta-table

https://community.databricks.com/t5/data-engineering/error-the-associated-location-is-not-empty-but-it-s-not-a-delta/m-p/7430#M3314

huangapple
  • 本文由 发表于 2023年7月11日 02:49:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76656527.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定