This article describes how to configure special and advanced driver capability settings for the Databricks JDBC Driver.
This article supplements the information in the following Databricks JDBC Driver articles:
To configure a Databricks connection for the Databricks JDBC Driver, you must combine your compute resource settings, authentication settings, and any of the following driver capability settings, into a JDBC connection URL or programmatic collection of JDBC connection properties. Whether you use a connection URL or a collection of connection properties will depend on the requirements of your target app, tool, client, SDK, or API. For examples of JDBC connection URLs and programmatic collections of JDBC connection properties, see Authentication settings for the Databricks JDBC Driver.
The Databricks JDBC Driver provides the following special and advanced driver capability settings.
Legacy Spark JDBC drivers accept SQL queries in ANSI SQL-92 dialect and translate the queries to the Databricks SQL dialect before sending them to the server. However, if your application generates Databricks SQL directly or your application uses any non-ANSI SQL-92 standard SQL syntax specific to Databricks, Databricks recommends that you set
UseNativeQuery=1 as a connection configuration. With that setting, the driver passes the SQL queries verbatim to Databricks.
To specify the default catalog and schema, add
ConnCatalog=<catalog-name>;ConnSchema=<schema-name> to the JDBC connection URL.
To achieve the best performance when you extract large query results, use the latest version of the JDBC driver, which includes the following optimizations.
JDBC driver version 2.6.16 and above supports an optimized query results serialization format that uses Apache Arrow.
The JDBC driver version 2.6.19 and above supports Cloud Fetch, a capability that fetches query results through the cloud storage that is set up in your Databricks deployment. To use Cloud Fetch to extract query results, use Databricks Runtime 8.3 or above.
Query results are uploaded to an internal DBFS storage location as Arrow-serialized files of up to 20 MB. When the driver sends fetch requests after query completion, Databricks generates and returns presigned URLs to the uploaded files. The JDBC driver then uses the URLs to download the results directly from DBFS.
Cloud Fetch is only used for query results larger than 1 MB. Smaller results are retrieved directly from Databricks.
Databricks automatically garbage collects the accumulated files which are marked for deletion after 24 hours. These marked files are completely deleted after an additional 24 hours.
Cloud Fetch is only available in E2 workspaces. Also, your corresponding Amazon S3 buckets must not have versioning enabled. If you have versioning enabled, you can still enable Cloud Fetch by following the instructions in Advanced configurations.
To learn more about the Cloud Fetch architecture, see How We Achieved High-bandwidth Connectivity With BI Tools.
If you have enabled S3 bucket versioning on your DBFS root, then Databricks cannot garbage collect older versions of uploaded query results. We recommend setting an S3 lifecycle policy first that purges older versions of uploaded query results.
To set a lifecycle policy follow the steps below:
In the AWS console, go to the S3 service.
Click on the S3 bucket that you use for your workspace’s root storage.
Open the Management tab and choose Create lifecycle rule.
Choose any name for the Lifecycle rule name.
Keep the prefix field empty.
Under Lifecycle rule actions select Permanently delete noncurrent versions of objects.
Set a value under Days after objects become noncurrent. We recommend using the value 1 here.
Click Create rule.