<?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: How to ingest files from volume using autoloader in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/how-to-ingest-files-from-volume-using-autoloader/m-p/55669#M6295</link>
    <description>&lt;P&gt;Hey, i think you are mixing DLT syntaxt with pyspark syntax:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;In DLT you should use:&lt;BR /&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class=""&gt;OR&lt;/SPAN&gt; &lt;SPAN class=""&gt;REFRESH&lt;/SPAN&gt; &lt;SPAN class=""&gt;STREAMING&lt;/SPAN&gt; &lt;SPAN class=""&gt;TABLE&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;table&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;name&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=""&gt;AS&lt;/SPAN&gt; &lt;SPAN class=""&gt;SELECT&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;*&lt;/SPAN&gt;
&lt;SPAN class=""&gt;FROM&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;STREAM&lt;/SPAN&gt; &lt;SPAN class=""&gt;read_files&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;'&amp;lt;path-to-source-data&amp;gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;format&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;'&amp;lt;file-format&amp;gt;'&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;or in Python&lt;BR /&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;@dlt&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;table&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;table_properties&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;SPAN class=""&gt;'quality'&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;'bronze'&lt;/SPAN&gt;&lt;SPAN class=""&gt;})&lt;/SPAN&gt;
&lt;SPAN class=""&gt;def&lt;/SPAN&gt; &lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;table&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;name&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;():&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;
     &lt;SPAN class=""&gt;spark&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;readStream&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;format&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'cloudFiles'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
     &lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;option&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'cloudFiles.format'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;'&amp;lt;file-format&amp;gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
     &lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;load&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;f&lt;/SPAN&gt;&lt;SPAN class=""&gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;path&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;to&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;source&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;data&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;SPAN class=""&gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
 &lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;You don't specified checkpoint for DLT in notebook&lt;BR /&gt;&lt;SPAN&gt;checkpoints are stored under the storage location specified in the DLT Pipeline settings&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;in PySaprk it is ok how you wrote it.&lt;BR /&gt;&lt;BR /&gt;I would avoid dumping your checkpoint to DBFS, create path in your storage and save it there.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Please let me know if that helps or please clarify if you are doing DLT or PySpark&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Dec 2023 11:40:09 GMT</pubDate>
    <dc:creator>Wojciech_BUK</dc:creator>
    <dc:date>2023-12-22T11:40:09Z</dc:date>
    <item>
      <title>How to ingest files from volume using autoloader</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-ingest-files-from-volume-using-autoloader/m-p/55612#M6294</link>
      <description>&lt;P&gt;I am doing a test run.&amp;nbsp; I am uploading files to a volume and then using autoloader to ingesgt files and creating a table. I am getting this error message:&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------&lt;/P&gt;&lt;P&gt;com.databricks.sql.cloudfiles.errors.CloudFilesIllegalStateException: The container in the file event `{"backfill":{"bucket":"root@dbstoragepdarecwn6h6go","key":"7019658555662308/FileStore/LiveDataUpload/wgs_hpo_test/2127020.HPO.txt","size":77,"eventTime":1703107647000}}` is different from expected by the source: `unitycatalog@bgdatabricksstoragev2`.&lt;/P&gt;&lt;P&gt;-------------------------------------&lt;/P&gt;&lt;P&gt;Here is the code to ingest the file from the specified location.&lt;/P&gt;&lt;P&gt;-------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;import dlt&lt;/P&gt;&lt;P&gt;from pyspark.sql.functions import col, current_timestamp, split&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;# Define variables used in code below&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;file_path = "/Volumes/bgem_dev/wgs_live/hpo/" &amp;nbsp;&lt;/P&gt;&lt;P&gt;username = spark.sql("SELECT regexp_replace(current_user(), '[^a-zA-Z0-9]', '_')").first()[0]&lt;/P&gt;&lt;P&gt;table_name = f"bgem_dev.wgs_live.hpo_test"&lt;/P&gt;&lt;P&gt;checkpoint_path = f"/tmp/{username}/_checkpoint/Live"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;# Clear out data from previous demo execution&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#spark.sql(f"DROP TABLE IF EXISTS {table_name}")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;#dbutils.fs.rm(checkpoint_path, True)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;(spark.readStream&lt;/P&gt;&lt;P&gt;&amp;nbsp; .format("cloudFiles")&lt;/P&gt;&lt;P&gt;&amp;nbsp; .option("cloudFiles.format", "text")&lt;/P&gt;&lt;P&gt;&amp;nbsp; .load(file_path)&lt;/P&gt;&lt;P&gt;&amp;nbsp; .select("*", col("_metadata.file_path").alias("source_file"), current_timestamp().alias("processing_time"))&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;.writeStream&lt;/P&gt;&lt;P&gt;&amp;nbsp; .option("checkpointLocation", checkpoint_path)&lt;/P&gt;&lt;P&gt;&amp;nbsp; .trigger(availableNow=True)&lt;/P&gt;&lt;P&gt;&amp;nbsp; .toTable(table_name)&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;</description>
      <pubDate>Thu, 21 Dec 2023 15:40:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-ingest-files-from-volume-using-autoloader/m-p/55612#M6294</guid>
      <dc:creator>pshuk</dc:creator>
      <dc:date>2023-12-21T15:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to ingest files from volume using autoloader</title>
      <link>https://community.databricks.com/t5/get-started-discussions/how-to-ingest-files-from-volume-using-autoloader/m-p/55669#M6295</link>
      <description>&lt;P&gt;Hey, i think you are mixing DLT syntaxt with pyspark syntax:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;In DLT you should use:&lt;BR /&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;CREATE&lt;/SPAN&gt; &lt;SPAN class=""&gt;OR&lt;/SPAN&gt; &lt;SPAN class=""&gt;REFRESH&lt;/SPAN&gt; &lt;SPAN class=""&gt;STREAMING&lt;/SPAN&gt; &lt;SPAN class=""&gt;TABLE&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;table&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;name&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=""&gt;AS&lt;/SPAN&gt; &lt;SPAN class=""&gt;SELECT&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;*&lt;/SPAN&gt;
&lt;SPAN class=""&gt;FROM&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;STREAM&lt;/SPAN&gt; &lt;SPAN class=""&gt;read_files&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;'&amp;lt;path-to-source-data&amp;gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;format&lt;/SPAN&gt; &lt;SPAN class=""&gt;=&amp;gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;'&amp;lt;file-format&amp;gt;'&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;or in Python&lt;BR /&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;@dlt&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;table&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;table_properties&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;SPAN class=""&gt;'quality'&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;'bronze'&lt;/SPAN&gt;&lt;SPAN class=""&gt;})&lt;/SPAN&gt;
&lt;SPAN class=""&gt;def&lt;/SPAN&gt; &lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;table&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;name&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;():&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;return&lt;/SPAN&gt; &lt;SPAN class=""&gt;(&lt;/SPAN&gt;
     &lt;SPAN class=""&gt;spark&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;readStream&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;format&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'cloudFiles'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
     &lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;option&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;'cloudFiles.format'&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;'&amp;lt;file-format&amp;gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
     &lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;load&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;f&lt;/SPAN&gt;&lt;SPAN class=""&gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;{&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;path&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;to&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;source&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN class=""&gt;data&lt;/SPAN&gt;&lt;SPAN class=""&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;}&lt;/SPAN&gt;&lt;SPAN class=""&gt;'&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
 &lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/PRE&gt;You don't specified checkpoint for DLT in notebook&lt;BR /&gt;&lt;SPAN&gt;checkpoints are stored under the storage location specified in the DLT Pipeline settings&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;LI&gt;&amp;nbsp;in PySaprk it is ok how you wrote it.&lt;BR /&gt;&lt;BR /&gt;I would avoid dumping your checkpoint to DBFS, create path in your storage and save it there.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Please let me know if that helps or please clarify if you are doing DLT or PySpark&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Dec 2023 11:40:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/how-to-ingest-files-from-volume-using-autoloader/m-p/55669#M6295</guid>
      <dc:creator>Wojciech_BUK</dc:creator>
      <dc:date>2023-12-22T11:40:09Z</dc:date>
    </item>
  </channel>
</rss>

