<?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: Schema Evolution/Type Widening in Materialized Views in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/schema-evolution-type-widening-in-materialized-views/m-p/129659#M48588</link>
    <description>&lt;P&gt;DLT supports schema evolution, but&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;changing column data types&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(like from&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DECIMAL(10,5)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DECIMAL(11,5)) is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;not automatically handled&lt;/STRONG&gt;. Here's how you can manage it:&lt;/P&gt;&lt;H4&gt;&lt;STRONG&gt;Option 1: Full Refresh with Schema Update&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;If you're okay with refreshing the materialized view (MV) or target table:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Update the schema in your DLT code&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(e.g., change the column type in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;StructType&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;definition).&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Use a helper function&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to process&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;_rescued_data&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and cast it to the new type.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Trigger a full refresh&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the affected table (e.g., silver layer) to apply the new schema.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This method keeps your MV intact and avoids reloading the bronze layer.&lt;/P&gt;&lt;H4&gt;&lt;STRONG&gt;Option 2: Append-Only Strategy with Union View&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;If you want to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;avoid full refreshes&lt;/STRONG&gt;:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;new version of the table&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(e.g.,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;silver_user_v1) with the updated schema.&lt;/LI&gt;&lt;LI&gt;Use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/97035"&gt;@Dlt&lt;/a&gt;.append_flow&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to append data from both old and new sources.&lt;/LI&gt;&lt;LI&gt;Create a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;view that unions&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;the old and new tables.&lt;/LI&gt;&lt;/OL&gt;</description>
    <pubDate>Mon, 25 Aug 2025 19:53:16 GMT</pubDate>
    <dc:creator>nayan_wylde</dc:creator>
    <dc:date>2025-08-25T19:53:16Z</dc:date>
    <item>
      <title>Schema Evolution/Type Widening in Materialized Views</title>
      <link>https://community.databricks.com/t5/data-engineering/schema-evolution-type-widening-in-materialized-views/m-p/129654#M48587</link>
      <description>&lt;P&gt;My team is migrating pipelines from Spark to Delta Live Tables (DLT), but we've found that some important features, like schema evolution for tables with enforced schemas, seem to be missing. In DLT, we can define schemas, set primary and foreign keys, add comments, and apply constraints. However, I can't find a way to manage changes to an enforced schema. For example, how can I update a column's data type from DECIMAL(10,5) to DECIMAL(11,5) without breaking the pipeline or having to fully reload the table?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;(i don't want to loose the schema of my mv table)&lt;/P&gt;</description>
      <pubDate>Mon, 25 Aug 2025 18:09:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/schema-evolution-type-widening-in-materialized-views/m-p/129654#M48587</guid>
      <dc:creator>ismaelhenzel</dc:creator>
      <dc:date>2025-08-25T18:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Schema Evolution/Type Widening in Materialized Views</title>
      <link>https://community.databricks.com/t5/data-engineering/schema-evolution-type-widening-in-materialized-views/m-p/129659#M48588</link>
      <description>&lt;P&gt;DLT supports schema evolution, but&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;changing column data types&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(like from&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DECIMAL(10,5)&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;DECIMAL(11,5)) is&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;not automatically handled&lt;/STRONG&gt;. Here's how you can manage it:&lt;/P&gt;&lt;H4&gt;&lt;STRONG&gt;Option 1: Full Refresh with Schema Update&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;If you're okay with refreshing the materialized view (MV) or target table:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;STRONG&gt;Update the schema in your DLT code&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(e.g., change the column type in the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;StructType&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;definition).&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Use a helper function&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to process&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;_rescued_data&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and cast it to the new type.&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Trigger a full refresh&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of the affected table (e.g., silver layer) to apply the new schema.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;This method keeps your MV intact and avoids reloading the bronze layer.&lt;/P&gt;&lt;H4&gt;&lt;STRONG&gt;Option 2: Append-Only Strategy with Union View&lt;/STRONG&gt;&lt;/H4&gt;&lt;P&gt;If you want to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;avoid full refreshes&lt;/STRONG&gt;:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Create a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;new version of the table&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(e.g.,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;silver_user_v1) with the updated schema.&lt;/LI&gt;&lt;LI&gt;Use&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/97035"&gt;@Dlt&lt;/a&gt;.append_flow&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to append data from both old and new sources.&lt;/LI&gt;&lt;LI&gt;Create a&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;view that unions&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;the old and new tables.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Mon, 25 Aug 2025 19:53:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/schema-evolution-type-widening-in-materialized-views/m-p/129659#M48588</guid>
      <dc:creator>nayan_wylde</dc:creator>
      <dc:date>2025-08-25T19:53:16Z</dc:date>
    </item>
  </channel>
</rss>

