<?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: Column Default Propagation in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/column-default-propagation/m-p/117734#M45558</link>
    <description>&lt;DIV class="paragraph"&gt;The behavior you described regarding the propagation of default column values is expected and is tied to the specific usage of the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; table property in Delta Lake. Here’s an explanation:&lt;/DIV&gt;
&lt;OL start="1"&gt;
&lt;LI&gt;
&lt;DIV class="paragraph"&gt;&lt;STRONG&gt;Default Propagation Without Transformation&lt;/STRONG&gt;: When creating a table (&lt;CODE&gt;schema.test2&lt;/CODE&gt;) via a &lt;CODE&gt;CREATE TABLE AS SELECT&lt;/CODE&gt; (CTAS) query, default column values from the source table (&lt;CODE&gt;schema.test&lt;/CODE&gt;) are transferred to the new table if the column is directly selected without applying transformations or type changes. This is why the &lt;CODE&gt;id&lt;/CODE&gt; column in the new table retains its default value. However, for this to work, the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property must be enabled on the target table.&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class="paragraph"&gt;&lt;STRONG&gt;Error Without &lt;CODE&gt;TBLPROPERTIES&lt;/CODE&gt; Set&lt;/STRONG&gt;: If the target table does not have the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property explicitly set to &lt;CODE&gt;'supported'&lt;/CODE&gt;, the CTAS operation fails with the error stating: &lt;CODE&gt;Failed to execute CREATE TABLE command because it assigned a column DEFAULT value, but the corresponding table feature was not enabled.&amp;lt;ref id="doc_1"/&amp;gt;&amp;lt;ref id="doc_2"/&amp;gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class="paragraph"&gt;&lt;STRONG&gt;Bypassing Default Propagation with Transformations&lt;/STRONG&gt;: If any operation (e.g., &lt;CODE&gt;CAST(id AS INT)&lt;/CODE&gt;) is applied to the column in the SELECT statement, the default value does not propagate. As a result, the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property does not need to be enabled, and the CTAS operation succeeds without the error.&lt;/DIV&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;H3&gt;Can This Behavior Be Changed or Disabled?&lt;/H3&gt;
&lt;DIV class="paragraph"&gt;Unfortunately, there isn’t a feature to disable this propagation behavior at the query level. However, you can handle this by: - &lt;STRONG&gt;Applying transformations&lt;/STRONG&gt; to the columns being selected, as this avoids default propagation. - &lt;STRONG&gt;Preemptively ensuring the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property is enabled&lt;/STRONG&gt; if maintaining defaults is the intended behavior for the target table.&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;This behavior is a design consideration in Delta Lake to ensure consistency between source and target schemas while using defaults when explicitly specified via the feature. Let me know if you'd like more information!&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;Hope this helps.&amp;nbsp; Big Roux.&lt;/DIV&gt;</description>
    <pubDate>Mon, 05 May 2025 15:45:17 GMT</pubDate>
    <dc:creator>Louis_Frolio</dc:creator>
    <dc:date>2025-05-05T15:45:17Z</dc:date>
    <item>
      <title>Column Default Propagation</title>
      <link>https://community.databricks.com/t5/data-engineering/column-default-propagation/m-p/117725#M45554</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; Today I found I somewhat strange behavior when it comes to default values in columns. Apparently, column defaults are propagated to a new table, when you select the column without any operation on it. This is a bit unexpected for me. Here a short example:&lt;BR /&gt;&lt;BR /&gt;I have a table where one of the columns has a default:&lt;BR /&gt;create or replace table schema.test (&lt;BR /&gt;&amp;nbsp; id int default 0,&lt;BR /&gt;&amp;nbsp; name string&lt;BR /&gt;)&lt;BR /&gt;TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported') -- needed as otherwise we can not define defaults&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;I insert some data and the use this as a basis for a new table:&lt;BR /&gt;create or replace table schema.test2&lt;BR /&gt;as&lt;BR /&gt;(select id, name from schema.test);&lt;BR /&gt;&lt;BR /&gt;this fails with the following error: [&lt;A href="https://docs.microsoft.com/azure/databricks/error-messages/error-classes#wrong_column_defaults_for_delta_feature_not_enabled" target="_blank" rel="noopener nofollow noreferrer"&gt;WRONG_COLUMN_DEFAULTS_FOR_DELTA_FEATURE_NOT_ENABLED&lt;/A&gt;] Failed to execute CREATE TABLE command because it assigned a column DEFAULT value, but the corresponding table feature was not enabled. Please retry the command again after executing ALTER TABLE tableName SET TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported').&lt;BR /&gt;&lt;BR /&gt;When I enable the table properties it works:&lt;BR /&gt;create or replace table schema.test2&lt;BR /&gt;TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'supported')&lt;BR /&gt;as&lt;U&gt; &lt;/U&gt;(select id, name from schema.test);&lt;BR /&gt;in this case the default will also be set on the id column of the new table, even though I have not explicitly set this.&lt;BR /&gt;&lt;BR /&gt;or when I do some operation on the column it works also without setting the table properties:&lt;BR /&gt;create or replace table schema.test2&lt;BR /&gt;as&lt;BR /&gt;(select cast(id as int), name from schema.test);&lt;BR /&gt;&lt;BR /&gt;is this expected behavior? Is there a way to disable this?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 05 May 2025 14:46:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/column-default-propagation/m-p/117725#M45554</guid>
      <dc:creator>meret</dc:creator>
      <dc:date>2025-05-05T14:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Column Default Propagation</title>
      <link>https://community.databricks.com/t5/data-engineering/column-default-propagation/m-p/117734#M45558</link>
      <description>&lt;DIV class="paragraph"&gt;The behavior you described regarding the propagation of default column values is expected and is tied to the specific usage of the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; table property in Delta Lake. Here’s an explanation:&lt;/DIV&gt;
&lt;OL start="1"&gt;
&lt;LI&gt;
&lt;DIV class="paragraph"&gt;&lt;STRONG&gt;Default Propagation Without Transformation&lt;/STRONG&gt;: When creating a table (&lt;CODE&gt;schema.test2&lt;/CODE&gt;) via a &lt;CODE&gt;CREATE TABLE AS SELECT&lt;/CODE&gt; (CTAS) query, default column values from the source table (&lt;CODE&gt;schema.test&lt;/CODE&gt;) are transferred to the new table if the column is directly selected without applying transformations or type changes. This is why the &lt;CODE&gt;id&lt;/CODE&gt; column in the new table retains its default value. However, for this to work, the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property must be enabled on the target table.&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class="paragraph"&gt;&lt;STRONG&gt;Error Without &lt;CODE&gt;TBLPROPERTIES&lt;/CODE&gt; Set&lt;/STRONG&gt;: If the target table does not have the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property explicitly set to &lt;CODE&gt;'supported'&lt;/CODE&gt;, the CTAS operation fails with the error stating: &lt;CODE&gt;Failed to execute CREATE TABLE command because it assigned a column DEFAULT value, but the corresponding table feature was not enabled.&amp;lt;ref id="doc_1"/&amp;gt;&amp;lt;ref id="doc_2"/&amp;gt;&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;DIV class="paragraph"&gt;&lt;STRONG&gt;Bypassing Default Propagation with Transformations&lt;/STRONG&gt;: If any operation (e.g., &lt;CODE&gt;CAST(id AS INT)&lt;/CODE&gt;) is applied to the column in the SELECT statement, the default value does not propagate. As a result, the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property does not need to be enabled, and the CTAS operation succeeds without the error.&lt;/DIV&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;H3&gt;Can This Behavior Be Changed or Disabled?&lt;/H3&gt;
&lt;DIV class="paragraph"&gt;Unfortunately, there isn’t a feature to disable this propagation behavior at the query level. However, you can handle this by: - &lt;STRONG&gt;Applying transformations&lt;/STRONG&gt; to the columns being selected, as this avoids default propagation. - &lt;STRONG&gt;Preemptively ensuring the &lt;CODE&gt;delta.feature.allowColumnDefaults&lt;/CODE&gt; property is enabled&lt;/STRONG&gt; if maintaining defaults is the intended behavior for the target table.&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;This behavior is a design consideration in Delta Lake to ensure consistency between source and target schemas while using defaults when explicitly specified via the feature. Let me know if you'd like more information!&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="paragraph"&gt;Hope this helps.&amp;nbsp; Big Roux.&lt;/DIV&gt;</description>
      <pubDate>Mon, 05 May 2025 15:45:17 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/column-default-propagation/m-p/117734#M45558</guid>
      <dc:creator>Louis_Frolio</dc:creator>
      <dc:date>2025-05-05T15:45:17Z</dc:date>
    </item>
  </channel>
</rss>

