Databricks
Try our fully managed solution to access this advanced feature.
Add credentials
- Create a new pipeline or open an existing pipeline.
- Expand the left side of your screen to view the file browser.
- Scroll down and click on a file named
io_config.yaml
. - Enter the following keys and values under the key named
default
(you can have multiple profiles, add it under whichever is relevant to you)
Using SQL Block with Databricks
Follow these steps to use a SQL block connected to Databricks in your pipeline.
-
Create or open a pipeline
Create a new pipeline or open an existing one. -
Add a block
Add a Data loader, Transformer, Data exporter, or Custom block. -
Select block type
Set the block type toSQL
. -
Configure the data provider
In theData provider
dropdown, selectDatabricks
. -
Choose a profile
In theProfile
dropdown, selectdefault
(or the profile you configured your Databricks credentials under). -
Configure output saving (optional)
By default, the SQL block saves query results to a table in your Databricks database.- Schema (optional): Enter the schema where the block’s output should be saved, default to the schema in
io_config.yaml
. - Table (optional): Enter the table where the block’s output should be saved, default table is generated based on block uuid.
- Write policy: Choose either
Replace
orAppend
. See the SQL blocks guide for more details on write policies. - If you don’t want to save results to an intermediate table, enable the Use raw SQL option. See the Raw SQL documentation for more information.
- Schema (optional): Enter the schema where the block’s output should be saved, default to the schema in
-
Enter a test query
Add a simple test query to confirm the connection works: -
Run the block
Click Run to execute the query and verify the block works as expected.
Using Python block
- Create a new pipeline or open an existing pipeline.
- Add a data loader, transformer, or data exporter block (the code snippet below is for a data loader).
- Select the
Data lakes -> Databricks SQL
template orGeneric (no template)
. - Enter this code snippet (note: change the
config_profile
fromdefault
if you have a different profile):
- Run the block.
Export a dataframe
Here is an example code snippet to export a dataframe to Databricks:
Method arguments
Field name | Description | Example values |
---|---|---|
allow_reserved_words | Whether to allow using reserved words as column names. | True/False (default: False) |
auto_clean_name | Whether to automatically clean the column name (replace the empty space with underscore, avoid using number as the prefix of the column name) | True/False (default: True) |
case_sensitive | Whether to support case sensitive columns | True/False (default: False) |
drop_table_on_replace | Whether to drop the table when “if_exists” param is set to “replace”. | True/False (default: False) |
if_exists | Specify resolution policy if table name already exists | ”fail”/“replace”/“append” (default: “replace”) |
Was this page helpful?