Serverless write options for bundled connectors
Writes to external data sources using bundled Spark connectors on serverless compute are in Public Preview.
When writing to an external data source using a bundled connector on serverless compute, only a subset of connector options are supported. The following tables list the supported options per connector.
For setup instructions and examples, see Spark data sources.
PostgreSQL
The following options are supported when writing to PostgreSQL on serverless compute.
Option | Description |
|---|---|
| Hostname of the PostgreSQL server. |
| Port number. Default: |
| Name of the database to connect to. |
| Maximum time in seconds to wait for a connection. |
| Database username. |
| Database password. |
| Target table name. Supports schema-qualified names (for example, |
| Number of rows to insert per batch. Default: |
| Number of Spark partitions for parallel write operations. |
| Maximum time in seconds to wait for a query to complete. |
| Transaction isolation level: |
| If |
| If |
SQL Server
The following options are supported when writing to SQL Server on serverless compute.
Option | Description |
|---|---|
| Hostname of the SQL Server instance. |
| Port number. Default: |
| Name of the database to connect to. |
| Maximum time in seconds to wait for a connection. |
| If |
| If |
| If |
| Database username. |
| Database password. |
| Authentication type. Supported values: |
| Target table name. Supports schema-qualified names (for example, |
| Number of rows to insert per batch. Default: |
| Number of Spark partitions for parallel write operations. |
| Maximum time in seconds to wait for a query to complete. |
| Transaction isolation level: |
| If |
MySQL
The following options are supported when writing to MySQL on serverless compute.
Option | Description |
|---|---|
| Hostname of the MySQL server. |
| Port number. Default: |
| Name of the database to connect to. |
| Maximum time in seconds to wait for a connection. |
| If |
| If |
| Database username. |
| Database password. |
| Target table name. Supports schema-qualified names (for example, |
| Number of rows to insert per batch. Default: |
| Number of Spark partitions for parallel write operations. |
| Maximum time in seconds to wait for a query to complete. |
| Transaction isolation level: |
| If |
| If |
Snowflake
The following sections list the supported options for the Snowflake connector, organized by function.
Connection
The following options configure the connection to Snowflake and control session behavior.
Option | Description |
|---|---|
| Snowflake account hostname (for example, |
| Port number. Default: |
| Snowflake account identifier. |
| Authentication method: |
| Timeout in seconds for network operations. |
| Timezone for timestamp operations (for example, |
| If |
| If |
Authentication
The following options supply credentials for the authentication method configured in sfauthenticator. Staging credentials (temporary_aws_*, awsaccesskey, temporary_azure_sas_token) are required when Snowflake stages write data through cloud storage.
Option | Description |
|---|---|
| Snowflake username. |
| Snowflake password. Used when |
| OAuth access token. Used when |
| Private key in PEM format for key-pair authentication. Used when |
| Temporary AWS access key ID for S3 staging. Preferred over |
| Temporary AWS secret access key for S3 staging. |
| Temporary AWS session token for S3 staging. |
| Temporary Azure SAS token for Azure Blob Storage staging. |
| AWS access key for S3 staging. |
| AWS secret key for S3 staging. |
Target
The following options specify the Snowflake database, schema, warehouse, and table to write to.
Option | Description |
|---|---|
| Snowflake database name. |
| Snowflake schema name. |
| Snowflake virtual warehouse used for query execution. |
| Snowflake role for the session. |
| Target table name. |
Write behavior
The following options control how data is written to the target Snowflake table.
Option | Description |
|---|---|
| How DataFrame columns are matched to Snowflake table columns: |
| Behavior when DataFrame and table columns don't align: |
| If |
| If |
| If |
| If |
Redshift
The following sections list the supported options for the Redshift connector, organized by function.
Connection
The following options configure the connection to the Redshift cluster.
Option | Description |
|---|---|
| Redshift cluster endpoint hostname. |
| Port number. Default: |
| Redshift database name. |
| Maximum time in seconds to wait for a connection. |
Authentication
The following options configure credentials for Redshift and for the S3 staging location that Redshift uses during write operations.
Option | Description |
|---|---|
| Redshift username. |
| Redshift password. |
| ARN of the IAM role that Redshift uses to access S3 for staging data. |
| Temporary AWS access key ID for S3 staging. Preferred over long-lived credentials. |
| Temporary AWS secret access key for S3 staging. |
| Temporary AWS session token for S3 staging. |
| If |
Write behavior
The following options control how data is written to the target Redshift table, including distribution, sort keys, and staging format.
Option | Description |
|---|---|
| Target table name. Supports schema-qualified names (for example, |
| Number of rows per batch insert. Default: |
| Number of Spark partitions for parallel write operations. |
| Maximum time in seconds to wait for a query to complete. |
| Transaction isolation level: |
| Redshift distribution style: |
| Column to use as the distribution key. Required when |
| Sort key specification for the Redshift table (for example, |
| String written in staging CSV files to represent |
| Staging file format: |
| If |
Write to PostgreSQL on serverless compute
This example uses append mode and retrieves credentials from a Databricks secret scope.
df.write \
.format("postgresql") \
.option("host", dbutils.secrets.get(scope="<scope>", key="<host>")) \
.option("port", "<port>") \
.option("database", "<database-name>") \
.option("dbtable", "<table-name>") \
.option("user", dbutils.secrets.get(scope="<scope>", key="<user>")) \
.option("password", dbutils.secrets.get(scope="<scope>", key="<password>")) \
.mode("append") \
.save()
Next steps
- Spark data sources: Setup instructions, code examples, and a comparison of Spark integration strategies.
- JDBC connection: Use a Unity Catalog connection with a JDBC driver for options not supported by bundled connectors on serverless, or for data sources without a bundled connector.
- Spark API options reference: Reference for DataFrameReader, DataFrameWriter, and streaming options for file formats and streaming sources.