<?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: Databricks Volume. Not able to read a file from Scala. in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/57851#M2282</link>
    <description>&lt;P class=""&gt;Volumes mount are accessible using scala code only on a shared cluster. On single user mode this features is not supported yet. We use init scripts to move contents from Volumes to clusters local drive, when we need to access files from Native Scala code. Volumes work out of the box for Spark APIs though - reading files, checkpoints, etc..&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;A href="https://docs.databricks.com/en/files/index.html" target="_blank" rel="noopener"&gt;https://docs.databricks.com/en/files/index.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;Important&lt;/P&gt;&lt;P class=""&gt;File operations that require FUSE access to data cannot directly access cloud object storage using URIs. Databricks recommends using Unity Catalog volumes to configure access to these locations for FUSE.&lt;/P&gt;&lt;P class=""&gt;Scala does not support FUSE for Unity Catalog volumes or workspace files on compute configured with &lt;STRONG&gt;assigned access mode or clusters without Unity Catalog&lt;/STRONG&gt;. Scala supports FUSE for Unity Catalog volumes and workspace files on compute configured with Unity Catalog and shared access mode.&lt;/P&gt;&lt;P class=""&gt;Try below code on a Shared vs Single user cluster,&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;%scala
import java.nio.file.Paths
import scala.io.Source
import java.nio.file.{FileSystems, Files}
import scala.collection.JavaConverters._

Files.list(Paths.get("/Volumes")).iterator().asScala.foreach(println) &lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 19 Jan 2024 02:16:44 GMT</pubDate>
    <dc:creator>argus7057</dc:creator>
    <dc:date>2024-01-19T02:16:44Z</dc:date>
    <item>
      <title>Databricks Volume. Not able to read a file from Scala.</title>
      <link>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/43073#M869</link>
      <description>&lt;P&gt;I used to use dbfs with mounted directories and now I want to switch to Volumes for storing my jars and application.conf for pipelines.&amp;nbsp;&lt;BR /&gt;I see the file my application.conf in Data Explorer &amp;gt; Catalog &amp;gt; Volumes, I also see the file with dbutils.fs.ls("/Volumes/.../path/to/file"),&lt;BR /&gt;but I'm not able to read it with Scala...&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;gt; dbutils.fs.ls("/Volumes/.../application.conf")&lt;BR /&gt;Cell output:&lt;BR /&gt;res52: Seq[com.databricks.backend.daemon.dbutils.FileInfo] = ArrayBuffer(FileInfo(/Volumes/.../application.conf, application.conf, 1602, 1693576640000))&lt;/P&gt;&lt;P&gt;My approaches:&lt;/P&gt;&lt;P&gt;1. pureconfig + custom case class&lt;BR /&gt;import pureconfig.{ConfigSource, ConfigReader, ConfigConvert}&lt;BR /&gt;import pureconfig.generic.auto._&lt;BR /&gt;val config = ConfigSource.file("/Volumes/.../application.conf")&lt;BR /&gt;config.loadOrThrow[Config]&lt;BR /&gt;Error:&amp;nbsp;ConfigReaderException: Cannot convert configuration to a Config. Failures are: - Unable to read file /Volumes/.../application.conf (No such file or directory).&lt;/P&gt;&lt;P&gt;2. Scala io Source&lt;BR /&gt;import scala.io.Source&lt;BR /&gt;Source.fromFile("/Volumes/.../application.conf")&lt;BR /&gt;Error:&amp;nbsp;FileNotFoundException: /Volumes/.../application.conf (No such file or directory)&lt;/P&gt;&lt;P&gt;3. java io&lt;BR /&gt;import java.io.{FileReader, File}&lt;BR /&gt;val fr = new FileReader(new File("/Volumes/.../application.conf"))&lt;BR /&gt;Error:&amp;nbsp;FileNotFoundException: /Volumes/.../application.conf (No such file or directory)&lt;/P&gt;&lt;P&gt;4. java nio&lt;BR /&gt;&lt;SPAN&gt;import java.nio.charset.StandardCharsets&lt;BR /&gt;&lt;/SPAN&gt;import java.nio.file.{Files, Paths}&lt;BR /&gt;val path = Paths.get("/Volumes/.../application.conf")&lt;BR /&gt;new String(Files.readAllBytes(path), StandardCharsets.UTF_8)&lt;BR /&gt;Error: FileNotFoundException: /Volumes/.../application.conf (No such file or directory)&lt;/P&gt;</description>
      <pubDate>Fri, 01 Sep 2023 14:41:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/43073#M869</guid>
      <dc:creator>Eldar_Dragomir</dc:creator>
      <dc:date>2023-09-01T14:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks Volume. Not able to read a file from Scala.</title>
      <link>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/43074#M870</link>
      <description>&lt;P&gt;Still not able to read with Scala, but it works fine with Python:&lt;/P&gt;&lt;DIV&gt;%python&lt;BR /&gt;with open('/Volumes/..../application.conf') as f:&lt;BR /&gt;s = f.read()&lt;BR /&gt;print(s)&lt;BR /&gt;Good output...&lt;BR /&gt;&lt;STRONG&gt;But I need a solution for Scala&lt;/STRONG&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 01 Sep 2023 14:53:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/43074#M870</guid>
      <dc:creator>Eldar_Dragomir</dc:creator>
      <dc:date>2023-09-01T14:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks Volume. Not able to read a file from Scala.</title>
      <link>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/43075#M871</link>
      <description>&lt;P&gt;5. java io + scala io&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;java&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;io&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;_&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;scala&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;io&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;_&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;val&lt;/SPAN&gt; &lt;SPAN&gt;file&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;File&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"/Volumes/.../application.conf"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;val&lt;/SPAN&gt; &lt;SPAN&gt;bufferedSource&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;BufferedSource&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;new&lt;/SPAN&gt; &lt;SPAN&gt;FileInputStream&lt;/SPAN&gt;&lt;SPAN&gt;(file))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; (line &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;-&lt;/SPAN&gt;&lt;SPAN&gt; bufferedSource.getLines) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; println(line)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;bufferedSource.close&lt;BR /&gt;&lt;/SPAN&gt;not works&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 01 Sep 2023 15:49:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/43075#M871</guid>
      <dc:creator>Eldar_Dragomir</dc:creator>
      <dc:date>2023-09-01T15:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Databricks Volume. Not able to read a file from Scala.</title>
      <link>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/57851#M2282</link>
      <description>&lt;P class=""&gt;Volumes mount are accessible using scala code only on a shared cluster. On single user mode this features is not supported yet. We use init scripts to move contents from Volumes to clusters local drive, when we need to access files from Native Scala code. Volumes work out of the box for Spark APIs though - reading files, checkpoints, etc..&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;&lt;A href="https://docs.databricks.com/en/files/index.html" target="_blank" rel="noopener"&gt;https://docs.databricks.com/en/files/index.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;Important&lt;/P&gt;&lt;P class=""&gt;File operations that require FUSE access to data cannot directly access cloud object storage using URIs. Databricks recommends using Unity Catalog volumes to configure access to these locations for FUSE.&lt;/P&gt;&lt;P class=""&gt;Scala does not support FUSE for Unity Catalog volumes or workspace files on compute configured with &lt;STRONG&gt;assigned access mode or clusters without Unity Catalog&lt;/STRONG&gt;. Scala supports FUSE for Unity Catalog volumes and workspace files on compute configured with Unity Catalog and shared access mode.&lt;/P&gt;&lt;P class=""&gt;Try below code on a Shared vs Single user cluster,&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;%scala
import java.nio.file.Paths
import scala.io.Source
import java.nio.file.{FileSystems, Files}
import scala.collection.JavaConverters._

Files.list(Paths.get("/Volumes")).iterator().asScala.foreach(println) &lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Jan 2024 02:16:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/databricks-volume-not-able-to-read-a-file-from-scala/m-p/57851#M2282</guid>
      <dc:creator>argus7057</dc:creator>
      <dc:date>2024-01-19T02:16:44Z</dc:date>
    </item>
  </channel>
</rss>

