<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Delta Live Table - Delta Table Sink Error after the first run in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/delta-live-table-delta-table-sink-error-after-the-first-run/m-p/119782#M45971</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a delta table sink to store delete requests coming to our system that are ingested in the bronze layer successfully with an autoloader. As I want to have a delete control table that needs to be updated after the data deletion, I wanted to create a Delta Teble Sink in my DLT pipeline.&lt;/P&gt;&lt;P&gt;The pipeline runs fine the first time, but after the first run it fails and I get the following error:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;com.databricks.sql.managedcatalog.UnityCatalogServiceException: [RequestId=f1e909e8-5738-4fe0-b57c-aa813b82b922 ErrorClass=TABLE_ALREADY_EXISTS.RESOURCE_ALREADY_EXISTS] Table 'delete_requests' already exists&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;this is how I defined the sink:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import dlt
from pyspark.sql.functions import col, lit
from pyspark.sql.types import DateType

dlt.create_sink(
  name = "delete_requests",
  format = "delta",
  options = { "tableName": "{{my_catalog}}.{{my_schema}}.delete_requests"}
)

@dlt.append_flow(name = "delta_sink_flow", target="delete_requests")
def delta_sink_flow():
  return(
  spark.readStream.table("{{my_catalog}}.{{my_schema}}.delete_user_service_reports")
  .withColumn("request_date", col("response_timestamp").cast("date"))
  .withColumn("delete_date", lit('1970-01-01').cast(DateType()))
  .select("user_id", "request_date", "delete_date")
  .distinct()
)&lt;/LI-CODE&gt;&lt;P&gt;Any idea why I have this error?&lt;/P&gt;</description>
    <pubDate>Tue, 20 May 2025 14:58:50 GMT</pubDate>
    <dc:creator>Luca_dall</dc:creator>
    <dc:date>2025-05-20T14:58:50Z</dc:date>
    <item>
      <title>Delta Live Table - Delta Table Sink Error after the first run</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-table-delta-table-sink-error-after-the-first-run/m-p/119782#M45971</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to create a delta table sink to store delete requests coming to our system that are ingested in the bronze layer successfully with an autoloader. As I want to have a delete control table that needs to be updated after the data deletion, I wanted to create a Delta Teble Sink in my DLT pipeline.&lt;/P&gt;&lt;P&gt;The pipeline runs fine the first time, but after the first run it fails and I get the following error:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;com.databricks.sql.managedcatalog.UnityCatalogServiceException: [RequestId=f1e909e8-5738-4fe0-b57c-aa813b82b922 ErrorClass=TABLE_ALREADY_EXISTS.RESOURCE_ALREADY_EXISTS] Table 'delete_requests' already exists&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;this is how I defined the sink:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import dlt
from pyspark.sql.functions import col, lit
from pyspark.sql.types import DateType

dlt.create_sink(
  name = "delete_requests",
  format = "delta",
  options = { "tableName": "{{my_catalog}}.{{my_schema}}.delete_requests"}
)

@dlt.append_flow(name = "delta_sink_flow", target="delete_requests")
def delta_sink_flow():
  return(
  spark.readStream.table("{{my_catalog}}.{{my_schema}}.delete_user_service_reports")
  .withColumn("request_date", col("response_timestamp").cast("date"))
  .withColumn("delete_date", lit('1970-01-01').cast(DateType()))
  .select("user_id", "request_date", "delete_date")
  .distinct()
)&lt;/LI-CODE&gt;&lt;P&gt;Any idea why I have this error?&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 14:58:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-table-delta-table-sink-error-after-the-first-run/m-p/119782#M45971</guid>
      <dc:creator>Luca_dall</dc:creator>
      <dc:date>2025-05-20T14:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Delta Live Table - Delta Table Sink Error after the first run</title>
      <link>https://community.databricks.com/t5/data-engineering/delta-live-table-delta-table-sink-error-after-the-first-run/m-p/119792#M45974</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/115711"&gt;@Luca_dall&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;It looks like this is trying to create the delta_sink_flow table each time the pipeline is run, where the creation of it should be managed by DLT. You can try removing the create_sink call and just run the append_flow to handle the table creation and write behavior.&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2025 17:03:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/delta-live-table-delta-table-sink-error-after-the-first-run/m-p/119792#M45974</guid>
      <dc:creator>Shua42</dc:creator>
      <dc:date>2025-05-20T17:03:01Z</dc:date>
    </item>
  </channel>
</rss>

