note
This article covers Databricks Connect for Databricks Runtime 13.3 LTS and above.
This article describes how to use Databricks Utilities with Databricks Connect for Scala. Databricks Connect enables you to connect popular IDEs, notebook servers, and custom applications to Databricks clusters. See What is Databricks Connect?. For the Python version of this article, see Databricks Utilities with Databricks Connect for Python.
You use Databricks Connect to access Databricks Utilities as follows:
DBUtils.getDBUtils
to access the Databricks File System (DBFS) and secrets through Databricks Utilities. DBUtils.getDBUtils
belongs to the Databricks Utilities for Scala library.build.sbt
for sbt
, pom.xml
for Maven, or build.gradle
for Gradle.DatabricksSession
class in your Databricks Connect project for Scala.The following example shows how to use the Databricks Utilities for Scala library to automate a Unity Catalog volume. This example creates a file named zzz_hello.txt
in the volume's path within the workspace, reads the data from the file, and then deletes the file.
Scala
import com.databricks.sdk.scala.dbutils.DBUtils
object Main {
def main(args: Array[String]): Unit = {
val filePath = "/Volumes/main/default/my-volume/zzz_hello.txt"
val fileData = "Hello, Databricks!"
val dbutils = DBUtils.getDBUtils()
dbutils.fs.put(
file = filePath,
contents = fileData,
overwrite = true
)
println(dbutils.fs.head(filePath))
dbutils.fs.rm(filePath)
}
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4