<?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 Re: Setup for Unity Catalog, autoloader, three-level namespace, SCD2 in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3726#M661</link>
    <description>&lt;P&gt;Hi @Jennette Shepard​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for posting your question in our community! We are happy to assist you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2023 07:17:18 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-06-14T07:17:18Z</dc:date>
    <item>
      <title>Setup for Unity Catalog, autoloader, three-level namespace, SCD2</title>
      <link>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3723#M658</link>
      <description>&lt;P&gt;I am trying to setup delta live tables pipelines to ingest data to bronze and silver tables. Bronze and Silver are separate schema.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will be triggered by a daily job.  It appears to run fine when set as continuous, but fails when triggered.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tables:&lt;/P&gt;&lt;P&gt;datasource.bronze.customer&lt;/P&gt;&lt;P&gt;datasource.silver.customerview&lt;/P&gt;&lt;P&gt;datasource.silver.customer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Currently the Unity Catalog integration with Delta Live Tables requires there to be separate pipelines for the bronze schema and the silver schema. Therefore I start by copying the data from bronze (datasource.bronze.customer) to silver (datasource.silver.customerview) as a pipeline cannot directly reference a table that was created outside of the pipeline. From that table (datasource.silver.customerview) I'm applying the changes to the silver table (datasource.silver.customer)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My setup is failing in the silver pipeline with the following error:&lt;/P&gt;&lt;P&gt;“Flow customer has FAILED fatally. An error occurred because we detected an update or delete to one or more rows in the source table. Streaming tables may only use append-only streaming sources. If you expect to delete or update rows to the source table in the future, please convert table customer to a live table instead of a streaming live table. To resolve this issue, perform a Full Refresh to table customer. A Full Refresh will attempt to clear all data from table customer and then load all data from the streaming source. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The non-append change can be found at version 16. &lt;/P&gt;&lt;P&gt;Operation: WRITE &lt;/P&gt;&lt;P&gt;Username: [Not specified] &lt;/P&gt;&lt;P&gt;Source table name: customerview”&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on this error or ways to correctly setup this dlt pipeline?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or even just an example/template/demo of how to set this up with unity catalog pipelines and the three-level-namespace would be much appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CODE:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;# Create temp silver table for UC workaround until three-level namespace is available
@dlt.table(
  name = viewNameSilver
)
def create_silver_temp_view():
  return spark.table(f'datasource.bronze.{tableNameBronze}')
&amp;nbsp;
# Create the target table definition
#create_streaming_live_table() - deprecated
#create_target_table() - deprecated
dlt.create_streaming_table(
  name = tableNameSilver,
  comment = f"Clean, merged {tableNameSilver}",
  table_properties = {
    "quality": "silver",
    "pipelines.autoOptimize.managed": "true"
  }
)
&amp;nbsp;
# apply scd2 to silver table
dlt.apply_changes(
  target = tableNameSilver,
  source = viewNameSilver,
  keys = primaryKeyCol,
  sequence_by = col('__EffectiveStartDate'),
  except_column_list = ['__EffectiveStartDate'],
  stored_as_scd_type = sCDType
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 00:45:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3723#M658</guid>
      <dc:creator>js54123875</dc:creator>
      <dc:date>2023-06-02T00:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Setup for Unity Catalog, autoloader, three-level namespace, SCD2</title>
      <link>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3724#M659</link>
      <description>&lt;P&gt;@Jennette Shepard​&amp;nbsp;as per below thread looks merges and deletes are not supported only append is supported and seems to be limitation, can you please follow recommendations based on below thread&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.databricks.com/s/question/0D53f00001sRRiGCAW/getting-error-when-using-cdc-in-delta-live-table" target="test_blank"&gt;https://community.databricks.com/s/question/0D53f00001sRRiGCAW/getting-error-when-using-cdc-in-delta-live-table&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 14:07:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3724#M659</guid>
      <dc:creator>karthik_p</dc:creator>
      <dc:date>2023-06-02T14:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Setup for Unity Catalog, autoloader, three-level namespace, SCD2</title>
      <link>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3725#M660</link>
      <description>&lt;P&gt;Thanks.  Since I'm running this in a triggered mode it feels like its reprocessing existing files. I wonder if I'm missing something in my definition of the bronze table? Shouldn't it only process new files (as long as I'm not doing a full refresh)? The existing files are not being changed, it should just read in the new file that was received each day.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my code for Bronze:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;@dlt.table(
      name=tableNameBronze,
      comment = "Raw data ingested from bronze",
      table_properties = {
        "myCompanyPipeline.quality" : "bronze",
        "pipelines.autoOptimize.managed": "true"
      }
    )
    def create_bronze():
      return (
        spark.readStream
          .format("cloudFiles")
          .option("cloudFiles.inferColumnTypes","false")
          .option("cloudFiles.schemaHints", schemaHintsBronze)
          .option("cloudFiles.format", sourceFormat)
          .option("cloudFiles.schemaEvolutionMode","rescue")
          .option("cloudFiles.rescuedDataColumn","__RescuedData")
          .option("pathGlobfilter", fileNamePrefix) 
          .load(dataPathBronze)
          .select(
            "*"
            ,col("_metadata.file_name").alias("__SourceFile")
            ,current_timestamp().alias("__IngestionDate")
            ,to_date(substring(col("_metadata.file_name"), -21, 8),'yyyyMMdd').alias("__EffectiveStartDate")
          )
        )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 14:48:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3725#M660</guid>
      <dc:creator>js54123875</dc:creator>
      <dc:date>2023-06-02T14:48:33Z</dc:date>
    </item>
    <item>
      <title>Re: Setup for Unity Catalog, autoloader, three-level namespace, SCD2</title>
      <link>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3726#M661</link>
      <description>&lt;P&gt;Hi @Jennette Shepard​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for posting your question in our community! We are happy to assist you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2023 07:17:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/setup-for-unity-catalog-autoloader-three-level-namespace-scd2/m-p/3726#M661</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-14T07:17:18Z</dc:date>
    </item>
  </channel>
</rss>

