This data connector enables you to import data from Databricks into Treasure Data.
- Basic knowledge of Treasure Data and access to a Treasure Data account
- Basic knowledge of Databricks and access to a Databricks account
- Access to a Databricks server
- If the Databricks server is in hibernation mode, it can take a few minutes to start, which may cause the connector to timeout.
Log in to the Databricks website.
Navigate to the SQL tab and then select SQL Warehouses.

Select an instance of an SQL Warehouse.

Select the Connection details tab.
Note the Server hostname and HTTP path for the SQL Warehouse.

Your first step is to create a new authentication with a set of credentials.
- Select Integrations Hub > Catalog.

- Search for databricks in the Catalog.
- Hover your mouse over the icon and select Create Authentication.

- Ensure that the Credentials tab is selected and then enter credential information for the integration.

| Parameter | Description |
|---|---|
| Hostname | This is the hostname of Databricks instance, |
| HTTP Path | This is the HTTP Path of Databricks instance. |
| Authentication Method | This is the authentication method: it can be be Basic or Personal Access Token. |
| Username | This is the username used to log in. It is only valid when the Authentication Method is Basic. |
| Password | This is the password used to log in. It is only valid when the Authentication Method is Basic. |
| Token | This is the Databricks personal access token. It is only valid when the Authentication Method is Personal Access Token. |
- Select Continue.
- Enter a name for your authentication, and select Done.
- Open TD Console.
- Navigate to Integrations Hub > Authentications.
- Locate your new authentication and select New Source.

- Type a source name in the Data Transfer Name field.
- Select Next.
| Parameter | Description |
|---|---|
| Data Transfer Name | This is the name for you data transfer source. |
| Authentication | This is the name of the authentication to be used. |
The Create Source page displays with the Source Table tab selected.

| Parameter | Description |
|---|---|
| Catalog | This is the dataset catalog. |
| Schema | This is the dataset schema. |
| Use custom SELECT query? | Select the checkbox to build a custom query, or fill in the fields to make a query. |
| Skip validate query? | Skip query syntax validation |
| Select Columns | Define columns to select from the dataset. This is required only if screen-shotUse custom SELECT queryscreen-shot is not selected. |
| Table | This is the table to select. Required only if screen-shotUse custom SELECT queryscreen-shot is not selected. |
| Filter Conditions | If you need additional specificity on the data retrieved from the table, you can specify it as part of WHERE clause. |
| Order by | Specify if you need the records ordered by a particular field. Incremental columns should be included in order by conditions. |
| Query | This field contains your SQL query. This is required only if screen-shotUse custom SELECT queryscreen-shot is selected. |
| Incremental Loading | Select the checkbox to enable incremental loading |
| Incremental Columns | Define incremental columns; these columns should be in the order by filter. |
| Start after value | This is the value for the columns used in incremental loading. |
| Invalid Value Handling Mode | Specify how to handle invalid values. You can select - Fail Job - Ignore Invalid Value - Ignore Row |
Select Next.
- Simple query:
query: SELECT * FROM simple_data WHERE cut = 'Very Good' ORDER BY `c_custkey`- Query with incremental and last_records
The value of the incremental\_columns should follow the position of parameters and have the same name as the column.
query: SELECT * FROM simple_data WHERE myid > :myid AND count > :count ORDER BY `myid`
incremental: true
incremental_columns: ['myid', 'count']
last_record: ['4', '5']The query must have a WHERE condition with values filled in for last\_record.
Order by is not required but should be specified to get more precise result
An actual query where screen-shotmyidscreen-shot is greater than 4 and screen-shotcountscreen-shot is greater than 5, would look something like this:
SELECT * FROM simple_data WHERE myid > 4 AND count > 5 ORDER BY `myid`
| Parameter | Description |
|---|---|
| COLUMN OPTIONS | Define data type for specific columns. |
| DEFAULT COLUMN_OPTIONS | Define conversion datatype for a specific datatype. For example: always convert a long to a string |
Select Next.
Data preview is optional, and you can safely click Next to go to the next page of the dialog if you would like.
Display a preview of your data before running the import by selecting Generate Preview.
The data shown in the data preview is approximated from your source. It is not the actual data that is imported.
Verify that the data looks approximately like you expect it to.

Select Next.
For data placement, select the target database and table where you want your data placed and indicate how often the import should run.
Select Next. Under Storage, you will create a new or select an existing database and create a new or select an existing table for where you want to place the imported data.
Select a Database > Select an existing or Create New Database.
Optionally, type a database name.
Select a Table> Select an existing or Create New Table.
Optionally, type a table name.
Choose the method for importing the data.
- Append (default)-Data import results are appended to the table. If the table does not exist, it will be created.
- Always Replace-Replaces the entire content of an existing table with the result output of the query. If the table does not exist, a new table is created.
- Replace on New Data-Only replace the entire content of an existing table with the result output when there is new data.
Select the Timestamp-based Partition Key column. If you want to set a different partition key seed than the default key, you can specify the long or timestamp column as the partitioning time. As a default time column, it uses upload_time with the add_time filter.
Select the Timezone for your data storage.
Under Schedule, you can choose when and how often you want to run this query.
- Select Off.
- Select Scheduling Timezone.
- Select Create & Run Now.
- Select On.
- Select the Schedule. The UI provides these four options: @hourly, @daily and @monthly or custom cron.
- You can also select Delay Transfer and add a delay of execution time.
- Select Scheduling Timezone.
- Select Create & Run Now.
After your transfer has run, you can see the results of your transfer in Data Workbench > Databases.
You can import data from Databricks by using the screen-shottd_load>:screen-shot operator for workflow. If you have already created a SOURCE, you can run it; if you don't want to create a SOURCE, you can import it using a screen-shot.ymlscreen-shot file.
- Open TD Console.
- Navigate to Integrations Hub > Sources.
- Identify your source.
- Select the more icon (...) on the far right of your source and then select Copy Unique ID.

The Unique ID will look something like this: screen-shotdatabricks_import_1234••••••screen-shot
- Define a workflow task using the screen-shottd_load>:screen-shot operator.
+load:
td_load>: databricks_import_1234••••••
database: ${td.dest_db}
Table: ${td.dest_table}- Run a workflow.
- Identify your screen-shot.ymlscreen-shot file.
If you need to create the screen-shot.ymlscreen-shot file, review Amazon S3 Import Integration Using CLI for reference.
- Define a workflow task using the screen-shottd_load>:screen-shot operator.
+load:
td_load>: config/daily_load.yml
database: ${td.dest_db}
table: ${td.dest_table}- Run a workflow
| Name | Description | Value | Default Value | Required |
|---|---|---|---|---|
| type | databricks | databricks | True | |
| auth_method | This is the authentication method. | basic or access_token | basic | |
host_name | This is the host name of the Databricks instance. | True | ||
http_path | This is the HTTP path of the Databricks instance. | True | ||
| user_name | This is the username for login. | True, if auth_method is basic. | ||
| password | This is the password for login. | True, if auth_method is basic. | ||
| access_token | This is the access_token to be used to fetch data. | True, if auth_method is access_token. | ||
| catalog | This is the dataset catalog. | True | ||
| schema | This is the dataset schema. | True | ||
| use_custom_query | You can build a custom query or fill in the fields to create a custom query. | true/false | true | |
| select | Define columns to select from dataset. This is Required only if screen-shotUse custom SELECT queryscreen-shotis false. | * | True, if use_custom_query is false. | |
| table | This is the table to select. This is Required only if screen-shotUse custom SELECT queryscreen-shot is false. | True, if use_custom_query is false. | ||
| where | If you need additional specificity on the data retrieved from the table, you can specify it as part of a WHERE clause. | |||
| order_by | Specify if you need the records ordered by a particular field. The incremental columns should be included in order by conditions. | |||
| query | Build your own query. | True, if use_custom_query is true. | ||
| incremental | Enable incremental loading. | true/false | false | |
incremental_columns | Define data type for specific columns. | |||
| last_record | Define the last record value for incremental loading. | |||
default_column_options | Define conversion datatype for a specific datatype. |
Visit Treasure Boxes for sample workflow code.
Before setting up the connector, install the most current TD Toolbelt.
in:
type: databricks
auth_method: BASIC
host_name: "dbc-8297d0a7-2709.cloud.databricks.com"
http_path: "/sql/1.0/warehouses/1b195ce3a8720eb9"
username: ***
password: ***
access_token: ***
catalog: hive_metastore
schema: default
select: "*"
table: diamonds
incremental_columns: [ price, x, y, z ]
order_by: "`price`, `x`, `y`, `z`"
incremental: true
last_record: ['4']
default_column_options: {"double": {"type": "string"}}
out:
mode: append| Name | Description | Value | Default Value | Required |
|---|---|---|---|---|
| type | databricks | databricks | True | |
| auth_method | This is the authentication method. | basic/access_token | basic | |
host_name | This is the host name of the Databricks instance. | True | ||
http_path | This is the HTTP path of the Databricks instance. | True | ||
| user_name | This is the username to log in. | True, if auth_method is basic. | ||
| password | This is the password to log in. | True, if auth_method is basic. | ||
| access_token | This is the access_token to fetch data. | True, if auth_method is access_token. | ||
| catalog | This is the dataset catalog. | True | ||
| schema | This is the the dataset schema. | True | ||
| use_custom_query | Build a custom query or fill in the fields to make a query . | true/false | true | |
| skip_validate_query | Skip query validation. If we skip query validation, preview mode always run with dummy data | true/false | false | |
| select | Define columns to select from the dataset. Required only ifscreen-shotUse custom SELECT queryscreen-shotis false. | * | True, if use_custom_query is false. | |
| table | This is the table to select. Required only if screen-shotUse custom SELECT queryscreen-shotis false. | True, if use_custom_query is false. | ||
| where | If you need additional specificity on the data retrieved from the table, you can specify it as part of a WHERE clause. | |||
| order_by | Specify if you need the records ordered by a particular field. The incremental columns should be included in order by conditions. | |||
| query | Build your own query. | True, if use_custom_query is true. | ||
| incremental | Enable incremental loading. | true/false | false | |
incremental_columns | Define the data type for specific columns. | |||
| last_record | Define the last record value for incremental loading. | |||
default_column_options | Define convert datatype for a specific datatype. |
The screen-shotconnector:guessscreen-shot command automatically reads the source files and uses logic to guess the file format, the fields, and columns.
$ td connector:guess seed.yml -o load.ymlYou can open the screen-shotload.ymlscreen-shot to review the definitions including file formats, encodings, column names, and types.
- Example
in:
type: databricks
auth_method: BASIC
host_name: "dbc-8297d0a7-2709.cloud.databricks.com"
http_path: "/sql/1.0/warehouses/1b195ce3a8720eb9"
username: ***
password: ***
access_token: ***
catalog: hive_metastore
schema: default
select: "*"
table: diamonds
incremental_columns: [ price, x, y, z ]
order_by: "`price`, `x`, `y`, `z`"
query: SELECT * FROM simple_data WHERE myid > :myid
incremental: true
last_record: ['4']
default_column_options: {"double": {"type": "string"}}
out:
mode: appendTo preview the data, use the screen-shottd connector:previewscreen-shot command.
$ td connector:preview load.yml
+-------+---------+----------+---------------------+
| id | company | customer | created_at |
+-------+---------+----------+---------------------+
| 11200 | AA Inc. | David | 2015-03-31 06:12:37 |
| 20313 | BB Imc. | Tom | 2015-04-01 01:00:07 |
| 32132 | CC Inc. | Fernando | 2015-04-01 10:33:41 |
| 40133 | DD Inc. | Cesar | 2015-04-02 05:12:32 |
| 93133 | EE Inc. | Jake | 2015-04-02 14:11:13 |
+-------+---------+----------+---------------------+The guess command requires more than 3 rows and 2 columns in the source data file because the command assesses the column definition using sample rows from the source data.
If the system detects your column name or column type unexpectedly, modify the screen-shotload.ymlscreen-shot file and preview again.
Executing a job might take a couple of hours depending on the size of the data. Be sure to specify the Treasure Data database and table where the data should be stored.
Treasure Data also recommends specifying the screen-shot*--time-columnscreen-shot option because Treasure Data’s storage is partitioned by time (see data partitioning). If this option is not provided, the data connector chooses the first long or timestamp column as the partitioning time. The type of the column specified by screen-shot--time-column*screen-shot must be either of type long or timestamp.
If your data doesn’t have a time column, you can add a time column by using the add_time filter option. For more details see add_time filter plugin.
$ td connector:issue load.yml --database td_sample_db --table td_sample_table \
--time-column created_atThis example command for screen-shotconnector:issuescreen-shot assumes that you have already created a screen-shotdatabase(td_sample_db)screen-shotand a screen-shottable(td_sample_table)screen-shot. If the database or the table does not exist in TD, this command fails. Create the database and table manually, or use the screen-shot--auto-create-tablescreen-shot option with the screen-shottd connector:issuescreen-shot command to auto-create the database and table.
$ td connector:issue load.yml --database td_sample_db --table td_sample_table
--time-column created_at --auto-create-tableThe data connector does not sort records on the server side. To use time-based partitioning effectively, sort the records in your files beforehand.
If you have a field called time, you don’t have to specify the --time-column option.
$ td connector:issue load.yml --database td_sample_db --table td_sample_tableYou can specify the file import mode in the out section of the screen-shotload.ymlscreen-shot file. The screen-shotout:screen-shot section controls how data is imported into a Treasure Data table. For example, you may choose to append data or replace data in an existing table in Treasure Data.
| Mode | Description | Examples |
|---|---|---|
| Append | Records are appended to the target table. | in: ... out: mode: append |
| Always Replace | This replaces data in the target table. Any manual schema changes made to the target table remain intact. | in: ... out: mode: replace |
| Replace on new data | This replaces data in the target table only when there is new data to import. | in: ... out: mode: replace_on_new_data |
You can schedule periodic data connector execution for incremental file import. Configure the scheduler carefully to ensure high availability.
For the scheduled import, you can import all files that match the specified prefix and one of these fields by condition:
- If screen-shotuse_modified_timescreen-shot is disabled, the last path is saved for the next execution. On the second and subsequent runs, the connector only imports files that come after the last path in alphabetical order.
- Otherwise, the time that the job is executed is saved for the next execution. On the second and subsequent runs, the connector only imports files that were modified after that execution time in alphabetical order.
All dates and as well as date/time formats that are specified without time zones are always treated as default UTC.
A new schedule can be created using the screen-shottd connector:createscreen-shotcommand.
$ td connector:create daily_import "10 0 * * *" \
td_sample_db td_sample_table load.ymlTreasure Data also recommends that you specify the --time-column option, because Treasure Data’s storage is partitioned by time (see also data partitioning).
td connector:create daily_import "10 0 * * *" \
td_sample_db td_sample_table load.yml \
--time-column created_atThe screen-shotcronscreen-shot parameter also accepts three special options: @hourly, @daily, and @monthly.
By default, the schedule is set up in the UTC timezone. You can set the schedule in a timezone using the screen-shot-tscreen-shot or screen-shot--timezone option.screen-shot The screen-shot--timezonescreen-shot option supports only extended timezone formats like 'Asia/Tokyo', 'America/Los_Angeles', etc. Timezone abbreviations like PST or CST are not supported and might lead to unexpected schedules.