<?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: Copy Into : Pattern for sub-folders in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/copy-into-pattern-for-sub-folders/m-p/54863#M30176</link>
    <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;We ended up implementing the programmatic approach to calculate the depth (using boto3).&lt;/P&gt;</description>
    <pubDate>Thu, 07 Dec 2023 13:28:50 GMT</pubDate>
    <dc:creator>Anup</dc:creator>
    <dc:date>2023-12-07T13:28:50Z</dc:date>
    <item>
      <title>Copy Into : Pattern for sub-folders</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-pattern-for-sub-folders/m-p/54656#M30140</link>
      <description>&lt;P&gt;While trying to ingest data from the S3 bucket, we are running into a situation where the data in s3 buckets is in sub-folders of multiple depths.&lt;/P&gt;&lt;P&gt;Is there a good way of specifying patterns for the above case?&lt;/P&gt;&lt;P&gt;We tried using the following for a depth of 4, and it works.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;%sql &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;COPY&lt;/SPAN&gt; &lt;SPAN&gt;INTO&lt;/SPAN&gt;&lt;SPAN&gt; table_name&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;FROM&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;s3://bucket_name&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;FILEFORMAT &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; BINARYFILE&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;PATTERN &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;/*/*/*/*&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;FORMAT_OPTIONS&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;mergeSchema&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;header&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;COPY_OPTIONS (&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;mergeSchema&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;true&lt;/SPAN&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;However, it is not always possible to know the exact depth for a large amount of random data.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;Has anyone run into this problem and was able to solve it?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 05 Dec 2023 14:40:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-pattern-for-sub-folders/m-p/54656#M30140</guid>
      <dc:creator>Anup</dc:creator>
      <dc:date>2023-12-05T14:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: Copy Into : Pattern for sub-folders</title>
      <link>https://community.databricks.com/t5/data-engineering/copy-into-pattern-for-sub-folders/m-p/54863#M30176</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/9"&gt;@Retired_mod&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;We ended up implementing the programmatic approach to calculate the depth (using boto3).&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 13:28:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/copy-into-pattern-for-sub-folders/m-p/54863#M30176</guid>
      <dc:creator>Anup</dc:creator>
      <dc:date>2023-12-07T13:28:50Z</dc:date>
    </item>
  </channel>
</rss>

