<?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 How do I use the Copy Into command to copy data into a Delta Table? Looking for examples where you want to have a pre-defined schema in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/how-do-i-use-the-copy-into-command-to-copy-data-into-a-delta/m-p/26863#M1493</link>
    <description>&lt;P&gt;I've reviewed the COPY INTO docs here - &lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/delta-copy-into.html#examples" target="test_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/delta-copy-into.html#examples&lt;/A&gt; but there's only one simple example. Looking for some additional examples that show loading data from CSV - with explicitly defined schema vs inferring it, etc&lt;/P&gt;</description>
    <pubDate>Fri, 14 May 2021 19:07:59 GMT</pubDate>
    <dc:creator>aladda</dc:creator>
    <dc:date>2021-05-14T19:07:59Z</dc:date>
    <item>
      <title>How do I use the Copy Into command to copy data into a Delta Table? Looking for examples where you want to have a pre-defined schema</title>
      <link>https://community.databricks.com/t5/machine-learning/how-do-i-use-the-copy-into-command-to-copy-data-into-a-delta/m-p/26863#M1493</link>
      <description>&lt;P&gt;I've reviewed the COPY INTO docs here - &lt;A href="https://docs.databricks.com/spark/latest/spark-sql/language-manual/delta-copy-into.html#examples" target="test_blank"&gt;https://docs.databricks.com/spark/latest/spark-sql/language-manual/delta-copy-into.html#examples&lt;/A&gt; but there's only one simple example. Looking for some additional examples that show loading data from CSV - with explicitly defined schema vs inferring it, etc&lt;/P&gt;</description>
      <pubDate>Fri, 14 May 2021 19:07:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/how-do-i-use-the-copy-into-command-to-copy-data-into-a-delta/m-p/26863#M1493</guid>
      <dc:creator>aladda</dc:creator>
      <dc:date>2021-05-14T19:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use the Copy Into command to copy data into a Delta Table? Looking for examples where you want to have a pre-defined schema</title>
      <link>https://community.databricks.com/t5/machine-learning/how-do-i-use-the-copy-into-command-to-copy-data-into-a-delta/m-p/26864#M1494</link>
      <description>&lt;P&gt;Here's an example for predefined schema&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Using&amp;nbsp;&lt;A href="https://urldefense.com/v3/__https:/docs.databricks.com/spark/latest/spark-sql/language-manual/delta-copy-into.html__;!!L8-7AA!BB-SWjosCaoHz2cvv6JkBJOd0y_ENO22V8PSiaEJ5M2H7AvblMtrqIamLGAqXQ$" alt="https://urldefense.com/v3/__https:/docs.databricks.com/spark/latest/spark-sql/language-manual/delta-copy-into.html__;!!L8-7AA!BB-SWjosCaoHz2cvv6JkBJOd0y_ENO22V8PSiaEJ5M2H7AvblMtrqIamLGAqXQ$" target="_blank"&gt;COPY INTO&lt;/A&gt;&amp;nbsp;with a predefined table schema – Trick here is to CAST the CSV dataset into your desired schema in the select statement of COPY INTO. Example below&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;I&gt;%sql&amp;nbsp;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;CREATE OR REPLACE TABLE copy_into_bronze_test&amp;nbsp;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;(id STRING, reading_time TIMESTAMP, device_type STRING, device_id STRING, device_operational_status STRING, reading_1 double, reading_2 double, reading_3 double)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;USING DELTA&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;%sql&amp;nbsp;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;COPY INTO copy_into_bronze_test&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;FROM&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;(&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;SELECT&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_c0 as ID,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CAST (_c1 AS timestamp) AS reading_time,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_c2 as device_type,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_c3 as device_id,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;_c4 as device_operational_status,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CAST(_c5 as double) as reading_1,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CAST(_c6 as double) as reading_2,&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CAST(_c7 as double) as reading_3&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;&amp;nbsp;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;FROM&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;'dbfs:/FileStore/flight/anand.ladda/*_no_headers.csv'&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;nbsp;)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;FILEFORMAT = CSV FORMAT_OPTIONS('sep' = ',','inferSchema' = 'false','header' = 'false')&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Jun 2021 20:32:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/how-do-i-use-the-copy-into-command-to-copy-data-into-a-delta/m-p/26864#M1494</guid>
      <dc:creator>aladda</dc:creator>
      <dc:date>2021-06-21T20:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use the Copy Into command to copy data into a Delta Table? Looking for examples where y</title>
      <link>https://community.databricks.com/t5/machine-learning/how-do-i-use-the-copy-into-command-to-copy-data-into-a-delta/m-p/64877#M3163</link>
      <description>&lt;P&gt;How does this work when you have 200 tables to load with each table having 50+ columns how to build this code in a generic way the csv file do not have the headers and when loaded without select its not taking predefined schema&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2024 07:19:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/how-do-i-use-the-copy-into-command-to-copy-data-into-a-delta/m-p/64877#M3163</guid>
      <dc:creator>DataInsight</dc:creator>
      <dc:date>2024-03-28T07:19:27Z</dc:date>
    </item>
  </channel>
</rss>

