03-20-2023 07:24 AM
I try to create a table but I get this error: AnalysisException: Cannot create table ('`spark_catalog`.`default`.`citation_all_tenants`'). The associated location ('dbfs:/user/hive/warehouse/citation_all_tenants') is not empty but it's not a Delta table
I checked the table location dbutils.fs.ls('dbfs:/user/hive/warehouse/') and there is the table with size= 0.
FileInfo(path='dbfs:/user/hive/warehouse/citation_all_tenants/', name='citation_all_tenants/', size=0, modificationTime=1678202578000),
I tried to delete table using this command dbutils.fs.rm('dbfs:/user/hive/warehouse/citation_all_tenants',recurse=True) but it does not remove it. My question is how to how to delete and recreate the table?
03-20-2023 09:16 AM
Hi @Chris Konsur , This issue generally happens when using "DROP TABLE" and "CREATE TABLE" commands. Databricks recommends to use "CREATE or REPLACE" commands to overwrite a delta table rather than dropping and recreating the table.
Also, to fix the issue you need to delete the table directory. You can try below methods for the same:
03-20-2023 08:53 AM
@Chris Konsur Hi. You did not mention the command you used to create the table. However the issue I could see here is that the table is already available in the catalog and you have to create a new table with the same name. If that's the case, the below two approaches could work.
Deleting the filesystem path will not remove your table entry from the catalog but dropping the table will remove your file path if it is a managed table. I see your table could be a managed table as the source path is hive warehouse path. Please try and let us know if this works.
03-20-2023 09:16 AM
Hi @Chris Konsur , This issue generally happens when using "DROP TABLE" and "CREATE TABLE" commands. Databricks recommends to use "CREATE or REPLACE" commands to overwrite a delta table rather than dropping and recreating the table.
Also, to fix the issue you need to delete the table directory. You can try below methods for the same:
03-20-2023 10:51 PM
Hi @Chris Konsur
Thank you for your question! To assist you better, please take a moment to review the answer and let me know if it best fits your needs.
Please help us select the best solution by clicking on "Select As Best" if it does.
Your feedback will help us ensure that we are providing the best possible service to you.
Thank you!
05-23-2024 11:51 PM
Hi Team, I am facing the same issue. When we try to load data to table in production batch getting error as table not in delta format. there is no recent change in table. and we are not trying any create or replace table. this is existing table in prod. this happened multiple times. we had to drop the table and clean the ABFS path to recreate. but this is not good approach as we might lose historical data. can some body guide why this error occurs when table is already in delta format.
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group