<?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: How integrate unique PK expectation into LDP pipeline graph in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141423#M51723</link>
    <description>&lt;P&gt;I know your solution is quite popular (just I don't get SELECT MAX(load_date) ). Another one is to use AUTO CDC even if you don't have CDC, as there is KEY option. If MAX(load_date) means that the last snapshot is most essential for you, please check the AUTO CDC from the SNAPSHOT.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Dec 2025 16:49:17 GMT</pubDate>
    <dc:creator>Hubert-Dudek</dc:creator>
    <dc:date>2025-12-08T16:49:17Z</dc:date>
    <item>
      <title>How integrate unique PK expectation into LDP pipeline graph</title>
      <link>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141419#M51719</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I'm working on a LDP and need help ensuring a downstream table only runs if a primary key unique validation check passes. In something like dbt this is very easy to configure but with LDP it seems to require creating a separate view. Additionally, it's not clear to me how to integrate that extra step into the pipeline graph since checking uniqueness requires aggregating.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Setup:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;LI-CODE lang="python"&gt;-- Step 1: Bronze streaming table
CREATE OR REFRESH STREAMING TABLE bronze_data AS
SELECT * FROM STREAM read_files('path/to/data/*.parquet');

-- Step 2: Silver table with deduplication
CREATE OR REFRESH MATERIALIZED VIEW silver_data AS
SELECT * FROM bronze_data
WHERE load_date = (SELECT MAX(load_date) FROM bronze_data);

-- Step 3: Separate PK validation table
CREATE OR REFRESH PRIVATE MATERIALIZED VIEW silver_data_pk_check(
  CONSTRAINT unique_pk EXPECT (record_count = 1)
  ON VIOLATION FAIL UPDATE
) AS 
SELECT primary_key, COUNT(*) as record_count
FROM silver_data
GROUP BY primary_key;

-- Step 4: Gold/Analytics table
CREATE OR REFRESH MATERIALIZED VIEW gold_data AS
SELECT * FROM silver_data
LEFT JOIN dimension_table ON ...;&lt;/LI-CODE&gt;&lt;P&gt;I guess i could force the dependency with a cross join or where exists but the whole thing feels weird. Is there a pattern how to do this?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2025 16:37:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141419#M51719</guid>
      <dc:creator>absan</dc:creator>
      <dc:date>2025-12-08T16:37:47Z</dc:date>
    </item>
    <item>
      <title>Re: How integrate unique PK expectation into LDP pipeline graph</title>
      <link>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141421#M51721</link>
      <description>&lt;P&gt;Yes — there is a clean, officially recommended pattern in LDP/Lakeflow, and it avoids all the “feels weird” hacks like CROSS JOIN, WHERE EXISTS, or artificial filters.&lt;/P&gt;&lt;P&gt;The correct pattern is:&lt;/P&gt;&lt;P&gt;Use a PRIVATE MV for the validation step + reference it (lightly) in the downstream MV&lt;/P&gt;&lt;P&gt;This creates a gating dependency without changing query semantics.&lt;/P&gt;&lt;P&gt;It is the Lakeflow equivalent of dbt tests gating downstream models.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2025 16:44:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141421#M51721</guid>
      <dc:creator>Poorva21</dc:creator>
      <dc:date>2025-12-08T16:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: How integrate unique PK expectation into LDP pipeline graph</title>
      <link>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141423#M51723</link>
      <description>&lt;P&gt;I know your solution is quite popular (just I don't get SELECT MAX(load_date) ). Another one is to use AUTO CDC even if you don't have CDC, as there is KEY option. If MAX(load_date) means that the last snapshot is most essential for you, please check the AUTO CDC from the SNAPSHOT.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2025 16:49:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141423#M51723</guid>
      <dc:creator>Hubert-Dudek</dc:creator>
      <dc:date>2025-12-08T16:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: How integrate unique PK expectation into LDP pipeline graph</title>
      <link>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141437#M51727</link>
      <description>&lt;P&gt;Thank you for your reply. Is this officially recommended pattern documented somewhere?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Dec 2025 17:41:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141437#M51727</guid>
      <dc:creator>absan</dc:creator>
      <dc:date>2025-12-08T17:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: How integrate unique PK expectation into LDP pipeline graph</title>
      <link>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141438#M51728</link>
      <description>&lt;P&gt;Thank you for the suggestion &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/25346"&gt;@Hubert-Dudek&lt;/a&gt;. I explored both those options however my data does not have a consistent key column that would allow me to use AUTO CDCs.&lt;/P&gt;&lt;P&gt;Instead, I'm grabbing the entire batch that was last loaded and then doing a replace downstream using&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;INSERT INTO&lt;/SPAN&gt; &lt;SPAN&gt;TABLE&lt;/SPAN&gt; &lt;SPAN&gt;gold&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;REPLACE&lt;/SPAN&gt; &lt;SPAN&gt;USING&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;loadkey&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT&lt;/SPAN&gt; &lt;SPAN&gt;*&lt;/SPAN&gt; &lt;SPAN&gt;FROM&lt;/SPAN&gt;&amp;nbsp;silver&lt;/PRE&gt;&lt;P&gt;Unfortunately, this last step is not supported in LDP so i have to run it as a separate step in the job. But it is very simple and works well.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 08 Dec 2025 17:56:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-integrate-unique-pk-expectation-into-ldp-pipeline-graph/m-p/141438#M51728</guid>
      <dc:creator>absan</dc:creator>
      <dc:date>2025-12-08T17:56:18Z</dc:date>
    </item>
  </channel>
</rss>

