<?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 Columns with DEFAULT missing error during INSERT in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/columns-with-default-missing-error-during-insert/m-p/36923#M26220</link>
    <description>&lt;P&gt;I am really confused about the DEFAULT capability of Databricks SQL. I looked at the documentation for the minimum required DBR to get the capability yet we still need to enable it as a table property? I updated my cluster's DBR from 12.2 to 13.1.&lt;/P&gt;&lt;P&gt;Anyway, that is already done. After having created my table, I am already set to do my INSERTs. Since I have set default values on 3 (out of 5) of my columns, I only provide the values for the two remaining columns. Yet for some reason, I am still forced to explicitly assign values to the columns with DEFAULTs assigned? What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Gim_0-1688465259125.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2757i60FC5523F518F189/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Gim_0-1688465259125.png" alt="Gim_0-1688465259125.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE OR REPLACE TABLE my_table (
  id BIGINT GENERATED BY DEFAULT AS IDENTITY,
  first_name STRING,
  last_name STRING,
  _is_active STRING DEFAULT 'Y',
  _start_date DATE DEFAULT CURRENT_DATE(),
  _end_date DATE DEFAULT NULL
)
TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'enabled', 'delta.minReaderVersion' = '2', 'delta.minWriterVersion'='7')
;

-- Initial data
INSERT INTO my_table (first_name, last_name)
SELECT fname, lname FROM src_table;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also referred to this &lt;A href="https://community.databricks.com/t5/data-engineering/using-current-timestamp-as-a-default-value-in-a-delta-table/m-p/11530/page/2" target="_blank" rel="noopener"&gt;link&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jul 2023 10:16:24 GMT</pubDate>
    <dc:creator>Gim</dc:creator>
    <dc:date>2023-07-04T10:16:24Z</dc:date>
    <item>
      <title>Columns with DEFAULT missing error during INSERT</title>
      <link>https://community.databricks.com/t5/data-engineering/columns-with-default-missing-error-during-insert/m-p/36923#M26220</link>
      <description>&lt;P&gt;I am really confused about the DEFAULT capability of Databricks SQL. I looked at the documentation for the minimum required DBR to get the capability yet we still need to enable it as a table property? I updated my cluster's DBR from 12.2 to 13.1.&lt;/P&gt;&lt;P&gt;Anyway, that is already done. After having created my table, I am already set to do my INSERTs. Since I have set default values on 3 (out of 5) of my columns, I only provide the values for the two remaining columns. Yet for some reason, I am still forced to explicitly assign values to the columns with DEFAULTs assigned? What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Gim_0-1688465259125.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2757i60FC5523F518F189/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="Gim_0-1688465259125.png" alt="Gim_0-1688465259125.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CREATE OR REPLACE TABLE my_table (
  id BIGINT GENERATED BY DEFAULT AS IDENTITY,
  first_name STRING,
  last_name STRING,
  _is_active STRING DEFAULT 'Y',
  _start_date DATE DEFAULT CURRENT_DATE(),
  _end_date DATE DEFAULT NULL
)
TBLPROPERTIES('delta.feature.allowColumnDefaults' = 'enabled', 'delta.minReaderVersion' = '2', 'delta.minWriterVersion'='7')
;

-- Initial data
INSERT INTO my_table (first_name, last_name)
SELECT fname, lname FROM src_table;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also referred to this &lt;A href="https://community.databricks.com/t5/data-engineering/using-current-timestamp-as-a-default-value-in-a-delta-table/m-p/11530/page/2" target="_blank" rel="noopener"&gt;link&lt;/A&gt;.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jul 2023 10:16:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/columns-with-default-missing-error-during-insert/m-p/36923#M26220</guid>
      <dc:creator>Gim</dc:creator>
      <dc:date>2023-07-04T10:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Columns with DEFAULT missing error during INSERT</title>
      <link>https://community.databricks.com/t5/data-engineering/columns-with-default-missing-error-during-insert/m-p/36925#M26221</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/64272"&gt;@Gim&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Got the same problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tried with the instruction "G&lt;SPAN&gt;ENERATED&lt;/SPAN&gt; &lt;SPAN&gt;ALWAYS&lt;/SPAN&gt; &lt;SPAN&gt;AS&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;CAST&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;CURRENT_DATE&lt;/SPAN&gt;&lt;SPAN&gt;() &lt;/SPAN&gt;&lt;SPAN&gt;AS&lt;/SPAN&gt; &lt;SPAN&gt;DATE&lt;/SPAN&gt;&lt;SPAN&gt;))" but code is returning&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;"Error in SQL statement: DeltaAnalysisException: current_date() cannot be used in a generated column"&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;If you find a solution other than generating the current date in your ingestion pipeline and inserting it with the data, please tell me&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;.&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Jul 2023 11:40:18 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/columns-with-default-missing-error-during-insert/m-p/36925#M26221</guid>
      <dc:creator>BriceBuso</dc:creator>
      <dc:date>2023-07-04T11:40:18Z</dc:date>
    </item>
  </channel>
</rss>

