How can I get rid of this error when writing a tab...
# replication-ask-ai
b
How can I get rid of this error when writing a table to databricks : java.sql.SQLException: [Databricks][JDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: 42P01, Query: COPY INTO *, Error message from Server: org.apache.hive.service.cli.HiveSQLException: Error running query: [DELTA_MISSING_DELTA_TABLE_COPY_INTO] com.databricks.sql.transaction.tahoe.DeltaAnalysisException: [DELTA_MISSING_DELTA_TABLE_COPY_INTO] Table doesn't exist. Create an empty Delta table first using CREATE TABLE
raw_data
.
airbyte_internal
.
coast_raw__stream_mad_airbyte_tmp
. at org.apache.spark.sql.hive.thriftserver.HiveThriftServerErrors$.runningQueryError(HiveThriftServerErrors.scala:49) at org.apache.spark.sql.hive.thriftserver.SparkExecuteStatementOperation.$anonfun$execute$1(SparkExecuteStatementOperation.scala:1050) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) at com.databricks.unity.UCSEphemeralState$Handle.runWith(UCSEphemeralState.scala:51) at com.databricks.unity.HandleImpl.runWith(UCSHandle.scala:104) at org.apache.spark.sql.hive.thriftserver.SparkExecuteStatementOperation.org$apache$spark$sql$hive$thriftserver$SparkExecuteStatementOperation$$execute(SparkExecuteStatementOperation.scala:787) at org.apache.spark.sql.hive.thriftserver.SparkExecuteStatementOperation$$anon$2$$anon$3.$anonfun$run$5(SparkExecuteStatementOperation.scala:578) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) at org.apache.spark.sql.execution.SQLExecution$.withRootExecution(SQLExecution.scala:869) at org.apache.spark.sql.hive.thriftserver.SparkExecuteStatementOperation$$anon$2$$anon$3.$anonfun$run$2(SparkExecuteStatementOperation.scala:578) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18) at com.databricks.logging.AttributionContextTracing.$anonfun$withAttributionContext$1(AttributionContextTracing.scala:80) at com.databricks.logging.AttributionContext$.$anonfun$withValue$1(AttributionContext.scala:348) at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59) at com.databricks.logging.AttributionContext$.withValue(AttributionContext.scala:344) at com.databricks.logging.AttributionContextTracing.withAttributionContext(AttributionContextTracing.scala:78) at com.databricks.logging.AttributionContextTracing.withAttributionContext$(AttributionContextTracing.scala:75) at com.databricks.spark.util.DatabricksTracingHelper.withAttributionContext(DatabricksSparkTracingHelper.scala:62) at com.databricks.spark.util.DatabricksTracingHelper.withSpanFromRequest(DatabricksSparkTracingHelper.scala:89) at com.databricks.spark.util.DBRTracing$.withSpanFromRequest(DBRTracing.scala:43) at org.apache.spark.sql.hive.thriftserver.ThriftLocalProperties.$anonfun$withLocalProperties$15(ThriftLocalProperties.scala:238) at com.databricks.logging.AttributionContextTracing.$anonfun$withAttributionContext$1(AttributionContextTracing.scala:80) at com.databricks.logging.AttributionContext$.$anonfun$withValue$1(AttributionContext.scala:348) at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59) at com.databricks.logging.AttributionContext$.withValue(AttributionContext.scala:344) at com.databricks.logging.AttributionContextTracing.withAttributionContext(AttributionContextTracing.scala:78) at com.databricks.logging.AttributionContextTracing.withAttributionContext$(AttributionContextTracing.scala:75) at com.databricks.spark.util.PublicDBLogging.withAttributionContext(DatabricksSparkUsageLogger.scala:29) at com.databricks.logging.AttributionContextTracing.withAttributionTags(AttributionContextTracing.scala:127) at com.databricks.logging.AttributionContextTracing.withAttributionTags$(AttributionContextTracing.scala:108) at com.databricks.spark.util.PublicDBLogging.withAttributionTags(DatabricksSparkUsageLogger.scala:29) at com.databricks.spark.util.PublicDBLogging.withAttributionTags0(DatabricksSparkUsageLogger.scala:108) at com.databricks.spark.util.DatabricksSparkUsageLogger.withAttributionTags(DatabricksSparkUsageLogger.scala:216) at com.databricks.spark.util.UsageLogging.$anonfun$withAttributionTags$1(UsageLogger.scala:668) at com.databricks.spark.util.UsageLogging$.withAttributionTags(UsageLogger.scala:780) at com.databricks.spark.util.UsageLogging$.withAttributionTags(UsageLogger.scala:789) at com.databricks.spark.util.UsageLogging.withAttributionTags(UsageLogger.scala:668) at com.databricks.spark.util.UsageLogging.withAttributionTags$(UsageLogger.scala:666) at org.apache.spark.sql.hive.thriftserver.SparkExecuteStatementOperation.withAttributionTags(SparkExecuteStatementOperation.scala:76) at org.apache.spark.sql.hive.thriftserver.ThriftLocalProperties.$anonfun$withLocalProperties$12(ThriftLocalProperties.scala:233) at com.databricks.spark.util.IdentityClaim$.withClaim(IdentityClaim.scala:48) at org.apache.spark.sql.hive.thriftserver.ThriftLocalProperties.withLocalProperties(ThriftLocalProperties.scala:229) at org.apache.spark.sql.hive.thriftserver.ThriftLocalProperties.withLocalProperties$(ThriftLocalProperties.scala:89) at org.apache.spark.sql.hive.thriftserver.SparkExecuteStatementOperation.withLocalProperties(SparkExecuteStatementOperation.scala:76) at
k
The knowledge sources don’t describe this exact error, but they do explain how the Databricks Lakehouse destination writes data and what Databricks expects, so I’ll base the answer on that and call out where I’m inferring behavior. Airbyte’s Databricks Lakehouse destination loads data in two steps: 1. It creates an empty Delta table:
Copy code
sql    CREATE OR REPLACE TABLE <table_name> AS SELECT * FROM <table_name> LIMIT 0
2. It then loads data into that table with:
Copy code
sql    COPY INTO <table_name>
[[Step 5](https://airbyte.com/tutorials/load-data-into-delta-lake-on-databricks-lakehouse#step-5)] Your error: >
[DELTA_MISSING_DELTA_TABLE_COPY_INTO] Table doesn't exist. Create an empty Delta table first using CREATE TABLE ...
means that when Databricks executes the
COPY INTO
step, it cannot find the target Delta table (
raw_data.airbyte_internal.coast_raw__stream_mad_airbyte_tmp
). In other words, the first step (“CREATE TABLE …”) either never ran successfully or ran against a different fully‑qualified name than the one used in
COPY INTO
. Given what’s in the docs, here are the concrete things to check/fix: 1. Unity Catalog path and schema are correct The Databricks destination requires Unity Catalog and a valid “Databricks Unity Catalog Path” (catalog + database) plus a default schema. [[Databricks dest](https://docs.airbyte.com/integrations/destinations/databricks)] Make sure: - The catalog and schema you configured in the destination actually exist. - The schema that Airbyte uses for raw tables (by default
airbyte_internal
, or whatever you set in
Raw Table Schema Name
) exists in that catalog/database. [[Databricks dest](https://docs.airbyte.com/integrations/destinations/databricks)] 2. Fully‑qualified table name matches what Databricks expects In Unity Catalog, tables are addressed as
catalog.schema.table
. Your error shows
raw_data.airbyte_internal.coast_raw__stream_mad_airbyte_tmp
. Confirm in Databricks SQL:
Copy code
sql    SHOW TABLES IN raw_data.airbyte_internal;
If the table is not there, then the
CREATE TABLE
step is failing or using a different catalog/schema than the
COPY INTO
step. 3. Check that Airbyte can create tables in that schema The connector needs permission to
CREATE TABLE
and
COPY INTO
in the target schema. If
CREATE TABLE
fails (permissions, path, etc.), Airbyte will still attempt
COPY INTO
and you’ll see exactly this “table doesn’t exist” error. The tutorial shows that, when it works, Airbyte creates the Delta table folder and then runs
COPY INTO
against it. [[Step 5](https://airbyte.com/tutorials/load-data-into-delta-lake-on-databricks-lakehouse#step-5)] 4. Verify the staging configuration The connector writes Parquet files to object storage (S3/GCS/Azure) and then uses
COPY INTO
from that location into the Delta table. [[Tutorial intro](https://airbyte.com/tutorials/load-data-into-delta-lake-on-databricks-lakehouse)] If the staging bucket/path or permissions are misconfigured, the
CREATE TABLE
or
COPY INTO
may fail. Compare your destination config with the example (S3 bucket, path, region, keys) and ensure the Databricks cluster can access that storage. [[Step 2–3](https://airbyte.com/tutorials/load-data-into-delta-lake-on-databricks-lakehouse#step-2)] 5. As a direct workaround, create the table once Since Databricks is explicitly telling you to “Create an empty Delta table first using CREATE TABLE …”, you can:
Copy code
sql    CREATE TABLE raw_data.airbyte_internal.coast_raw__stream_mad_airbyte_tmp    USING DELTA    LOCATION 's3://<your-bucket>/<path>/raw_data/airbyte_internal/coast_raw__stream_mad_airbyte_tmp';
(Adjust catalog/schema/location to match your Unity Catalog path and the S3 path Airbyte is using.) After that, re‑run the sync so that
COPY INTO
has a table to target. Because the knowledge sources don’t include this exact stack trace, I can’t point to a specific known bug or version issue. If, after checking catalog/schema, permissions, and staging config, the table still isn’t created before
COPY INTO
, then this is likely a connector bug or environment‑specific issue and you’d need to share the full sync logs with Airbyte support or on the forum for deeper debugging.