<?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 Insert into delta table fails in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/insert-into-delta-table-fails/m-p/20257#M1114</link>
    <description>&lt;P&gt;Hello experts. We are trying to execute an insert command with less columns than the target table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Insert into table_name( col1, col2, col10)&lt;/P&gt;&lt;P&gt;Select col1, col2, col10&lt;/P&gt;&lt;P&gt;from table_name2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the above fails with:&lt;/P&gt;&lt;P&gt;Error in SQL statement: DeltaAnalysisException: Column col3 is not specified in INSERT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know if INSERT using a subquery requires all the columns of the target table specified?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Nov 2022 13:26:02 GMT</pubDate>
    <dc:creator>elgeo</dc:creator>
    <dc:date>2022-11-28T13:26:02Z</dc:date>
    <item>
      <title>Insert into delta table fails</title>
      <link>https://community.databricks.com/t5/machine-learning/insert-into-delta-table-fails/m-p/20257#M1114</link>
      <description>&lt;P&gt;Hello experts. We are trying to execute an insert command with less columns than the target table:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Insert into table_name( col1, col2, col10)&lt;/P&gt;&lt;P&gt;Select col1, col2, col10&lt;/P&gt;&lt;P&gt;from table_name2&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However the above fails with:&lt;/P&gt;&lt;P&gt;Error in SQL statement: DeltaAnalysisException: Column col3 is not specified in INSERT&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you know if INSERT using a subquery requires all the columns of the target table specified?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 13:26:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/insert-into-delta-table-fails/m-p/20257#M1114</guid>
      <dc:creator>elgeo</dc:creator>
      <dc:date>2022-11-28T13:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Insert into delta table fails</title>
      <link>https://community.databricks.com/t5/machine-learning/insert-into-delta-table-fails/m-p/20258#M1115</link>
      <description>&lt;P&gt;Hi @ELENI GEORGOUSI​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes. When you are doing an insert, your provided schema should match with the target schema else it would throw an error.&lt;/P&gt;&lt;P&gt;But you can still insert the data using another approach. Create a dataframe with your data having less columns and when writing that data into the target path, enable the mergeSchema option. This way even if you are adding new columns or removing columns, data would not be lost.&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Nov 2022 18:51:19 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/insert-into-delta-table-fails/m-p/20258#M1115</guid>
      <dc:creator>UmaMahesh1</dc:creator>
      <dc:date>2022-11-29T18:51:19Z</dc:date>
    </item>
  </channel>
</rss>

