<?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: Autoloader, toTable in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/autoloader-totable/m-p/58283#M31083</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/98663"&gt;@ShlomoSQM&lt;/a&gt;&amp;nbsp;-&amp;nbsp; Please refer to the below steps and let us know if it works&lt;/P&gt;
&lt;P&gt;1) Add a column(with column) for filename during&amp;nbsp;&lt;SPAN&gt;readStream data from autoloader using&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;input_file_name() function&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2) split the dataframe (df to df1, df2)&amp;nbsp; into two based on type1 and type2 (using file name contains type1.. say for example) using schema 1 and schema 2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3) using merge statement, insert/update the data to the table1 and table2 with the respective dataframes for type1(df1), df2.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Jan 2024 16:09:15 GMT</pubDate>
    <dc:creator>shan_chandra</dc:creator>
    <dc:date>2024-01-23T16:09:15Z</dc:date>
    <item>
      <title>Autoloader, toTable</title>
      <link>https://community.databricks.com/t5/data-engineering/autoloader-totable/m-p/58273#M31078</link>
      <description>&lt;P&gt;"In autoloader there is the option ".toTable(catalog.volume.table_name)", I have an autoloder script that reads all the files from a source volume in unity catalog, inside the source I have two different files with two different schemas.&lt;BR /&gt;I want to send them to two tables: catalog.volume.table_name1 (for files of type 1) and catalog.volume.table_name2 (for files of type2), how can I specify this in the readStream options or in the writeStream options part?"&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 23 Jan 2024 14:26:27 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/autoloader-totable/m-p/58273#M31078</guid>
      <dc:creator>ShlomoSQM</dc:creator>
      <dc:date>2024-01-23T14:26:27Z</dc:date>
    </item>
    <item>
      <title>Re: Autoloader, toTable</title>
      <link>https://community.databricks.com/t5/data-engineering/autoloader-totable/m-p/58283#M31083</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/98663"&gt;@ShlomoSQM&lt;/a&gt;&amp;nbsp;-&amp;nbsp; Please refer to the below steps and let us know if it works&lt;/P&gt;
&lt;P&gt;1) Add a column(with column) for filename during&amp;nbsp;&lt;SPAN&gt;readStream data from autoloader using&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;input_file_name() function&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2) split the dataframe (df to df1, df2)&amp;nbsp; into two based on type1 and type2 (using file name contains type1.. say for example) using schema 1 and schema 2.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3) using merge statement, insert/update the data to the table1 and table2 with the respective dataframes for type1(df1), df2.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 16:09:15 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/autoloader-totable/m-p/58283#M31083</guid>
      <dc:creator>shan_chandra</dc:creator>
      <dc:date>2024-01-23T16:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Autoloader, toTable</title>
      <link>https://community.databricks.com/t5/data-engineering/autoloader-totable/m-p/58305#M31095</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/98663"&gt;@ShlomoSQM&lt;/a&gt;, looks like &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/616"&gt;@shan_chandra&lt;/a&gt;&amp;nbsp;suggested a feasible solution, just to add a little more context this is how you can achieve the same if you have a column that can help you identify what is type1 and type 2&lt;/P&gt;&lt;LI-CODE lang="python"&gt;file_type1_stream = readStream.option("cloudFiles.format", "parquet") \
                              .load("/mnt/source_volume") \
                              .filter(col("file_type") == "type1")  # Assuming a column indicating file type

file_type2_stream = readStream.option("cloudFiles.format", "parquet") \
                              .load("/mnt/source_volume") \
                              .filter(col("file_type") == "type2")

file_type1_stream.writeStream.format("delta") \
                            .option("checkpointLocation", "/mnt/checkpoints/type1") \
                            .toTable("catalog.volume.table_name1")

file_type2_stream.writeStream.format("delta") \
                            .option("checkpointLocation", "/mnt/checkpoints/type2") \
                            .toTable("catalog.volume.table_name2")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 06:31:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/autoloader-totable/m-p/58305#M31095</guid>
      <dc:creator>Palash01</dc:creator>
      <dc:date>2024-01-24T06:31:10Z</dc:date>
    </item>
  </channel>
</rss>

