<?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 to Read a Source Table Once and Reuse It Across Multiple Materialized Views in LDP/DLT in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178207#M57504</link>
    <description>&lt;P&gt;In Declarative Pipelines, every decorated function becomes an independent dataset with its own refresh query and Spark DataFrames are inherently lazy. spark.read.table("source_table") captures a logical plan but not data. Module level source_df variable looks like it reads once but nothing is executed at assignment time. When the pipeline refreshes each of the five materialized views builds and runs its own physical plan from that shared logical plan - so the source table gets scanned five separate times with once per MV. There is no implicit caching across independently scheduled queries.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Materialize&lt;/STRONG&gt; the shared read once. The right pattern is to promote the common source read to its own materialized view. It gets computed and persisted once per update like any MV and keep it &lt;STRONG&gt;private. &lt;/STRONG&gt;It&amp;nbsp;keeps it &lt;STRONG&gt;invisible&lt;/STRONG&gt; to the catalog and downstream consumers and exists as a pipeline scoped &lt;STRONG&gt;staging&lt;/STRONG&gt; step. All five downstream MVs then read from that materialized intermediate instead of the raw source, so the scan happens once and the five views each do targeted work on top of it. On serverless compute it compounds nicely - materialized views are supported incremental sources, so the downstream MVs can refresh &lt;STRONG&gt;incrementally&lt;/STRONG&gt; against the &lt;STRONG&gt;staging&lt;/STRONG&gt; &lt;STRONG&gt;MV&lt;/STRONG&gt; (processing upstream changes since the last update) and DP model decides increment vs full recompute automatically. Enable &lt;STRONG&gt;row tracking&lt;/STRONG&gt; and &lt;STRONG&gt;deletion vectors&lt;/STRONG&gt; on the &lt;STRONG&gt;source&lt;/STRONG&gt; &lt;STRONG&gt;table&lt;/STRONG&gt; to maximize incremental eligibility.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Staging MV
@dp.materialized_view(name="source_base", private=True)
def source_base():
    return spark.read.table("source_table")

# Downstream MV reads the materialized staging MV — no repeated source scans
@dp.materialized_view(name="mv_1")
def mv_1():
    return spark.read.table("source_base").filter("condition_1")

@dp.materialized_view(name="mv_2")
def mv_2():
    return spark.read.table("source_base").filter("condition_2")

@dp.materialized_view(name="mv_3")
def mv_3():
    return spark.read.table("source_base").filter("condition_3")&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 30 Nov 2026 11:59:59 GMT</pubDate>
    <dc:creator>balajij8</dc:creator>
    <dc:date>2026-11-30T11:59:59Z</dc:date>
    <item>
      <title>How to Read a Source Table Once and Reuse It Across Multiple Materialized Views in LDP/DLT</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178192#M57500</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Can we read one source table once and reuse it across five Materialized Views without triggering repeated source scans in DLT?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;source_df = spark.read.table("source_table")&lt;/P&gt;&lt;P&gt;dp.materialized_view(name="mv_1")&lt;BR /&gt;def mv_1():&lt;BR /&gt;return source_df.filter("condition_1")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;dp.materialized_view(name="mv_2")&lt;BR /&gt;def mv_2():&lt;BR /&gt;return source_df.filter("condition_2")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;dp.materialized_view(name="mv_3"&lt;BR /&gt;def mv_3():&lt;BR /&gt;return source_df.filter("condition_3")&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2026 11:23:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178192#M57500</guid>
      <dc:creator>surajitDE</dc:creator>
      <dc:date>2026-11-30T11:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to Read a Source Table Once and Reuse It Across Multiple Materialized Views in LDP/DLT</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178201#M57502</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Defining &lt;/SPAN&gt;&lt;SPAN&gt;source_df&lt;/SPAN&gt;&lt;SPAN&gt; outside the materialized view functions does not guarantee that the source table is scanned only once. Spark uses lazy evaluation, and Lakeflow evaluates dataset definitions independently as part of the pipeline execution graph.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would recommend creating a shared intermediate materialized view.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;from pyspark import pipelines as dp

@dp.materialized_view(name="shared_source", private=True)
def shared_source():
    return spark.read.table("catalog.schema.source_table")

@dp.materialized_view(name="mv_1")
def mv_1():
    return spark.read.table("shared_source").filter("region = 'India'")

@dp.materialized_view(name="mv_2")
def mv_2():
    return spark.read.table("shared_source").filter("region = 'USA'")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;This creates a persisted intermediate dataset that downstream materialized views can reuse without independently recomputing the original source transformations.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;A few important distinctions:&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;A temporary view does not guarantee materialization.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;A private materialized view persists intermediate results without publishing them externally.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;SPAN&gt;Downstream materialized views may still scan the intermediate dataset independently.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN&gt;For example, if the source requires expensive joins and transformations, materializing that shared logic can avoid repeating the same computation across five downstream views.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My recommendation is to use a shared intermediate materialized view when the common transformations are expensive. For simple filters, benchmark both approaches because additional materialization also introduces storage and refresh overhead.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN&gt;Official references:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/ldp/developer/ldp-python-ref-materialized-view" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://docs.databricks.com/aws/en/ldp/developer/ldp-python-ref-materialized-view&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/ldp/materialized-views" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://docs.databricks.com/aws/en/ldp/materialized-views&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/aws/en/ldp/developer/python-ref" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;https://docs.databricks.com/aws/en/ldp/developer/python-ref&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2026 11:35:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178201#M57502</guid>
      <dc:creator>tajamulkhan</dc:creator>
      <dc:date>2026-11-30T11:35:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Read a Source Table Once and Reuse It Across Multiple Materialized Views in LDP/DLT</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178207#M57504</link>
      <description>&lt;P&gt;In Declarative Pipelines, every decorated function becomes an independent dataset with its own refresh query and Spark DataFrames are inherently lazy. spark.read.table("source_table") captures a logical plan but not data. Module level source_df variable looks like it reads once but nothing is executed at assignment time. When the pipeline refreshes each of the five materialized views builds and runs its own physical plan from that shared logical plan - so the source table gets scanned five separate times with once per MV. There is no implicit caching across independently scheduled queries.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Materialize&lt;/STRONG&gt; the shared read once. The right pattern is to promote the common source read to its own materialized view. It gets computed and persisted once per update like any MV and keep it &lt;STRONG&gt;private. &lt;/STRONG&gt;It&amp;nbsp;keeps it &lt;STRONG&gt;invisible&lt;/STRONG&gt; to the catalog and downstream consumers and exists as a pipeline scoped &lt;STRONG&gt;staging&lt;/STRONG&gt; step. All five downstream MVs then read from that materialized intermediate instead of the raw source, so the scan happens once and the five views each do targeted work on top of it. On serverless compute it compounds nicely - materialized views are supported incremental sources, so the downstream MVs can refresh &lt;STRONG&gt;incrementally&lt;/STRONG&gt; against the &lt;STRONG&gt;staging&lt;/STRONG&gt; &lt;STRONG&gt;MV&lt;/STRONG&gt; (processing upstream changes since the last update) and DP model decides increment vs full recompute automatically. Enable &lt;STRONG&gt;row tracking&lt;/STRONG&gt; and &lt;STRONG&gt;deletion vectors&lt;/STRONG&gt; on the &lt;STRONG&gt;source&lt;/STRONG&gt; &lt;STRONG&gt;table&lt;/STRONG&gt; to maximize incremental eligibility.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Staging MV
@dp.materialized_view(name="source_base", private=True)
def source_base():
    return spark.read.table("source_table")

# Downstream MV reads the materialized staging MV — no repeated source scans
@dp.materialized_view(name="mv_1")
def mv_1():
    return spark.read.table("source_base").filter("condition_1")

@dp.materialized_view(name="mv_2")
def mv_2():
    return spark.read.table("source_base").filter("condition_2")

@dp.materialized_view(name="mv_3")
def mv_3():
    return spark.read.table("source_base").filter("condition_3")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Nov 2026 11:59:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178207#M57504</guid>
      <dc:creator>balajij8</dc:creator>
      <dc:date>2026-11-30T11:59:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to Read a Source Table Once and Reuse It Across Multiple Materialized Views in LDP/DLT</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178354#M57532</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/126180"&gt;@surajitDE&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am following up on the answers to this thread. Thank you for including the code. It made the test quick to set up.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TL;DR:&lt;/STRONG&gt; A pipeline has no construct that reads a source once and hands the rows to five materialized views. Each materialized view is its own flow with its own query, so each one reads its source. Incremental refresh keeps those five reads cheap: After the first update, each view processes only the changes since the last refresh, with its filter pushed down to them where possible. In my test with the code you shared, both a temporary view and a private materialized view were refreshed incrementally on the second update.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Sharing how the three patterns read the source:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Your module-level DataFrame:&lt;/STRONG&gt; &lt;CODE&gt;source_df&lt;/CODE&gt; holds a query plan with no data. &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/python-ref#coding-requirements-for-python-pipelines" target="_blank"&gt;A pipeline evaluates its source code multiple times during planning and runs&lt;/A&gt;, and each materialized view builds its own query from that plan. All five read &lt;CODE&gt;source_table&lt;/CODE&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;A temporary view:&lt;/STRONG&gt; &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/ldp-python-ref-view" target="_blank"&gt;Its results are calculated when queried&lt;/A&gt;, and it &lt;A href="https://docs.databricks.com/aws/en/ldp/best-practices/#choose-the-right-dataset-type" target="_blank"&gt;stores no data&lt;/A&gt;. As&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/211605"&gt;@tajamulkhan&lt;/a&gt;&amp;nbsp;wrote, the five views still read the source.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;A private materialized view:&lt;/STRONG&gt; The table is &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/ldp-python-ref-materialized-view#parameters" target="_blank"&gt;visible only inside the pipeline&lt;/A&gt; and &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/sql-dev#define-a-private-table" target="_blank"&gt;persists across updates&lt;/A&gt;. The five views then read the copy, one read each. They refresh incrementally against it, as&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/210897"&gt;@balajij8&lt;/a&gt;&amp;nbsp; mentioned. The copy adds storage and a sixth flow.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;What makes the five reads cheap:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Changeset filters:&lt;/STRONG&gt; &lt;A href="https://docs.databricks.com/aws/en/ldp/incremental-refresh#filters-and-predicate-pushdown" target="_blank"&gt;Where possible, filters are also pushed down to the changeset, so that changes outside the filter aren't processed&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Row tracking and deletion vectors:&lt;/STRONG&gt;&amp;nbsp;This is&amp;nbsp;&lt;A href="https://docs.databricks.com/aws/en/ldp/incremental-refresh#optimize-materialized-views" target="_blank"&gt;recommended both on all materialized view source tables&lt;/A&gt;. Some incremental operations require row tracking.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Serverless:&lt;/STRONG&gt; &lt;A href="https://docs.databricks.com/aws/en/ldp/incremental-refresh#refresh-types-for-materialized-views" target="_blank"&gt;Incremental refresh is only available when the compute you are connected to is serverless&lt;/A&gt;. On classic compute, each update recomputes all five views from the full source.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG style="color: #183139;"&gt;When a private materialized view pays off:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;It pays off when the shared step costs more than the read, for example, joins, aggregations, or heavy transformations.&lt;/SPAN&gt;&amp;nbsp;For a plain read with a filter, as in your code, the copy moves the five reads onto itself and adds storage and a refresh.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Before you rely on this:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;STRONG&gt;Testing:&lt;/STRONG&gt; I ran each pattern as its own serverless pipeline on AWS on 1 Dec 2026, against a 2,000,000-row source with five region filters. Update 1 computed every view in full. After I added 1,000 rows for one region, update 2 chose APPEND_ONLY for every view in all three pipelines, and for the private copy. Executor time per view stayed under a second in every pattern, too close to rank.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Decorators:&lt;/STRONG&gt; The post shows &lt;CODE&gt;dp.materialized_view(...)&lt;/CODE&gt; without the &lt;CODE&gt;@&lt;/CODE&gt;, which the forum editor may have dropped. If your file has no &lt;CODE&gt;@&lt;/CODE&gt; either, Python discards the decorator and the pipeline defines no table.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Loops:&lt;/STRONG&gt; If you build the five views in a loop, wrap each definition in a function, as in the code below. The docs explain why under &lt;A href="https://docs.databricks.com/aws/en/ldp/developer/python-dev#troubleshooting-for-loop-creates-many-tables-with-same-values" target="_blank"&gt;for loop creates many tables with same values&lt;/A&gt;.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Clustering an existing table:&lt;/STRONG&gt; &lt;CODE&gt;ALTER TABLE ... CLUSTER BY&lt;/CODE&gt; &lt;A href="https://docs.databricks.com/aws/en/tables/clustering#enable-on-existing-tables" target="_blank"&gt;does not apply clustering to previously written data&lt;/A&gt;. Run &lt;CODE&gt;OPTIMIZE ... FULL&lt;/CODE&gt; once to recluster it.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;Check before you act:&lt;/STRONG&gt; After the second update, run the event log query below. Each view's entry lists one technique with &lt;CODE&gt;"is_chosen":true&lt;/CODE&gt;. A &lt;CODE&gt;maintenance_type&lt;/CODE&gt; that ends in COMPLETE_RECOMPUTE on a later update means that view read the whole source again.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;The temporary view pattern I tested, with your table name in &lt;CODE&gt;SRC&lt;/CODE&gt; and your conditions in place of the regions:&lt;/P&gt;
&lt;PRE&gt;from pyspark import pipelines as dp

src='catalog.schema.source_table'
REGIONS = ['India', 'USA', 'UK', 'Germany', 'Japan']


@dp.temporary_view(name='source_view')
def source_view():
    return spark.read.table(SRC)


def define_mv(n, region):
    @dp.materialized_view(name=f'mv_{n}')
    def mv():
        return spark.read.table('source_view').filter(f"region = '{region}'")


for n, region in enumerate(REGIONS, 1):
    define_mv(n, region)&lt;/PRE&gt;
&lt;P&gt;The source table settings, then the event log check, with your pipeline ID in place of &lt;CODE&gt;PIPELINE_ID&lt;/CODE&gt;:&lt;/P&gt;
&lt;PRE&gt;ALTER TABLE catalog.schema.source_table CLUSTER BY (region);
ALTER TABLE catalog.schema.source_table SET TBLPROPERTIES (
  'delta.enableRowTracking' = 'true',
  'delta.enableDeletionVectors' = 'true');
OPTIMIZE catalog.schema.source_table FULL;

SELECT origin.flow_name, details:planning_information:technique_information
FROM event_log('PIPELINE_ID')
WHERE event_type = 'planning_information'
ORDER BY timestamp DESC;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Reference documentation:&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/ldp/incremental-refresh" target="_blank"&gt;Incremental refresh for materialized views&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/ldp/developer/python-ref" target="_blank"&gt;Lakeflow pipelines Python language reference&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://docs.databricks.com/aws/en/ldp/developer/python-dev" target="_blank"&gt;Develop pipeline code with Python&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Happy to rerun the test with your real filter columns if you share them. Results from anyone who has compared these patterns on a larger source would also help here.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Dec 2026 14:03:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-a-source-table-once-and-reuse-it-across-multiple/m-p/178354#M57532</guid>
      <dc:creator>LingeshK</dc:creator>
      <dc:date>2026-12-01T14:03:16Z</dc:date>
    </item>
  </channel>
</rss>

