class Builder extends Logging
- Alphabetic
- By Inheritance
- Builder
- Logging
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit class LogStringContext extends AnyRef
- Definition Classes
- Logging
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def MDC(key: LogKey, value: Any): MDC
- Attributes
- protected
- Definition Classes
- Logging
- def addCompiledArtifacts(uri: URI): Builder
Upload the compiled artifacts to the Databricks cluster and synchronize as part of session initialization.
Upload the compiled artifacts to the Databricks cluster and synchronize as part of session initialization.
This is required when the program requires external dependencies to evaluate the Spark query. For any Spark query using a typed Dataset API such as filter(), map(), foreach(), etc., or if the query is using a UDF, the enclosing classes should be synchronized with the cluster.
For example: the following code snippet includes the compiled artifact of class
Foo. Theuriin this example will either point to a JAR file or to a folder that contains the compiled class files.val uri = Foo.getClass.getProtectionDomain.getCodeSource.getLocation.toURI val spark = DatabricksSession.builder() .addCompiledArtifacts(uri) ...
- uri
Specify the class file, JAR or directory to upload and synchronize. When a directory is specified, all deep nested JARs and class files will be synchronized.
- returns
instance of this Builder
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def clusterId(clusterId: String): Builder
The Databricks cluster id to connect.
The Databricks cluster id to connect. Can't be used with serverless(enabled=True) at the same time.
- clusterId
cluster id
- returns
instance of Builder with the cluster id configured
- def configureSessionAfterCreation(spark: SparkSession): Unit
- Attributes
- protected
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def fromSparkClientConf(conf: Configuration): SparkSession
- Attributes
- protected[connect]
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def getOrCreate(): SparkSession
Get a spark session if one was already created with the given configuration.
Get a spark session if one was already created with the given configuration. Otherwise, create a new one.
Connection parameters for connecting to Databricks Connect is collected in the following order. When one of the configuration parameters is collected, the lookup for that parameter stops; collection for other parameters continues down the chain.
- Parameters configured directly in code via host(), token(), etc.
- Parameters configured in the Databricks SDK's DatabricksConfig specified via sdkConfig()
- The
SPARK_REMOTEenvironment variable. For details on the connection string, see https://github.com/apache/spark/blob/master/sql/connect/docs/client-connection-string.md - Use the "default" configuration profile from the Databricks config file. For details on Databricks configuration profiles, see https://docs.databricks.com/dev-tools/auth.html
By default, validates the used configuration by retrieving the used Databricks Runtime version with the Databricks SDK. Logs a warning if the authentication fails or if there is an unsupported combination of Databricks Runtime & Databricks Connect versions. Change this behaviour with DatabricksSession.builder().validateSession().
- returns
spark session
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def header(header: String, value: String): Builder
Add a header to the Spark Connect GRPC requests.
Add a header to the Spark Connect GRPC requests. This method is cumulative (can be called repeatedly to add more headers).
- header
Name of the header to set
- value
The value to set
- returns
The same instance of this class with a header set.
- def host(host: String): Builder
The URL of the Databricks workspace to connect.
The URL of the Databricks workspace to connect.
- host
Databricks workspace URL
- returns
instance of Builder with the host configured
- def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def initializeLogIfNecessary(isInterpreter: Boolean): Unit
- Attributes
- protected
- Definition Classes
- Logging
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTraceEnabled(): Boolean
- Attributes
- protected
- Definition Classes
- Logging
- def log: Logger
- Attributes
- protected
- Definition Classes
- Logging
- def logBasedOnLevel(level: Level)(f: => MessageWithContext): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logDebug(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logError(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logInfo(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logName: String
- Attributes
- protected
- Definition Classes
- Logging
- def logNativeProto(dbrLogBytes: Array[Byte]): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logTrace(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(msg: => String, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(entry: LogEntry, throwable: Throwable): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(entry: LogEntry): Unit
- Attributes
- protected
- Definition Classes
- Logging
- def logWarning(msg: => String): Unit
- Attributes
- protected
- Definition Classes
- Logging
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def remote(): Builder
API returns the same instance of the builder unchanged.
API returns the same instance of the builder unchanged. This API is here for backwards compatibility.
- returns
instance of Builder
- def sdkConfig(config: DatabricksConfig): Builder
Provide a custom SDK Config object to use for connection configuration.
Provide a custom SDK Config object to use for connection configuration. Can be used to override the default SDK Config that will be used.
- config
Databricks SDK Config
- returns
instance of Builder with the host configured
- def serverless(enabled: Boolean = true, usagePolicyId: Option[String] = None): Builder
[IMPORTANT]: This API and support for Scala in serverless is in early PRIVATE PREVIEW.
[IMPORTANT]: This API and support for Scala in serverless is in early PRIVATE PREVIEW. Some operations may not work.
Connect to the serverless endpoint of the workspace. Can't be used with clusterId at the same time.
- enabled
Boolean flag that enables serverless mode.
- usagePolicyId
Private Preview API. Not yet supported in Databricks notebooks and jobs. The usage policy for running serverless workloads on Databricks compute. If no usage policy is specified, the workload is run using the unrestricted usage policy or the workspace default usage policy, if the user is entitled to one of them. If the specified policy does not exist or if the user is not entitled to it, an error will be thrown.
- returns
instance of Builder with the serverless mode configured
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def token(token: String): Builder
The access token to use while for connecting.
The access token to use while for connecting. The user associated with this token should have access to the workspace and cluster. Subsequent queries will be executed on behalf of this user.
- token
Databricks access token
- returns
instance of Builder with the access token configured
- def userAgent(userAgent: String): Builder
A user agent string identifying the application using the Databricks Connect module.
A user agent string identifying the application using the Databricks Connect module. Databricks Connect sends a set of standard information, such as, OS, Python version and the version of Databricks Connect included as a user agent to the service. The value provided here will be included along with the rest of the information. It is recommended to provide this value in the format "<product-name>/<product-version>" as described in https://datatracker.ietf.org/doc/html/rfc7231#section-5.5.3, but is not required.
- userAgent
The user agent string identifying the application that is using this module.
- returns
instance of Builder with the cluster id configured
- def validateSession(enabled: Boolean = true): Builder
Setting this option will run validations and throw an error if any fail.
Setting this option will run validations and throw an error if any fail. Validations are run only when connecting to a Databricks cluster.
- the specified connection parameters are valid and can communicate with the cluster
- the Databricks Runtime version of the cluster is greater than or equal to the Databricks Connect version. By default, these validations are run and a warning is logged. Unsetting this option will turn off these validations. Skipping validations for connections strings.
- enabled
Boolean, optional
- returns
instance of Builder with validateSession option configured
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def withLogContext(context: Map[String, String])(body: => Unit): Unit
- Attributes
- protected
- Definition Classes
- Logging
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)