Databricks - Insert

Overview

You can use this Snap to run a Databricks SQL Insert statement with a set of values to insert in the target Databricks Lakehouse Platform (DLP) table. The Snap treats each key-value pair specified in the input document as the column to insert into, and the corresponding value to insert. For the columns not specified in the input document, the Snap inserts null values in the row.



Prerequisites

  • Valid access credentials to a DLP instance with adequate access permissions to perform the action in context.
  • Valid access to the external source data in one of the following: Azure Blob Storage, ADLS Gen2, DBFS, GCP, AWS S3, or another database (JDBC-compatible).

Limitations

Snaps in the Databricks Snap Pack do not support array, map, and struct data types in their input and output documents.

Snap views

View Description Examples of upstream and downstream Snaps
Input A JSON document containing the key-value pairs indicating the columns and values for the new rows to insert in the DLP table.
  • If a second input view is configured for the Snap and it contains a document with schema (metadata) of the source table, the Snap creates the new (target) table using the same schema (metadata). However, if the schema comes from a different database, the Snap might fail with Unable to create table: "<table_name>" error due to data type incompatibility.

  • In the absence of a second input view (the schema/metadata document), the Snap creates a table based on the data types of the columns generated from the first row of the input document (first input view).

Output A JSON document containing each SQL statement along with its execution status (or result).
Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the pipeline by choosing one of the following options from the When errors occur list under the Views tab. The available options are:

  • Stop Pipeline Execution Stops the current pipeline execution when an error occurs.
  • Discard Error Data and Continue Ignores the error, discards that record, and continues with the remaining records.
  • Route Error Data to Error View Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap settings

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field / Field set Type Description
Label String

Required. Specify a unique name for the Snap. Modify this to be more appropriate, especially if more than one of the same Snaps is in the pipeline.

Default value: Databricks - Insert

Example: Db_Insert_Customer
Use unity catalog Checkbox Select this checkbox to use the Unity catalog to access data from the catalog.

Default status: Deselected

Catalog name String/Expression/ Suggestion Specify the name of the catalog for using the unity catalog.

Default value: hive_metastore

Example: xyzcatalog

Database name String/Expression/ Suggestion Enter your corresponding DLP database name for the INSERT statement to add new rows in the table.

Default value: None.

Example: Cust_DB

Table name String/Expression/ Suggestion Required. Enter your table name for the INSERT statement to add new rows.

Default value: None.

Example: Cust_List

Number of Retries Integer/Expression Specifies the maximum number of retry attempts when the Snap fails to write.

Minimum value: 0

Default value: 0

Example: 3

Retry Interval (seconds) Integer/Expression Specifies the minimum number of seconds the Snap must wait before each retry attempt.

Minimum value: 1

Default value: 1

Example: 3

Manage Queued Queries Dropdown list Select this property to determine whether the Snap should continue or cancel the execution of the queued Databricks SQL queries when you stop the Pipeline.
Note: If you select Cancel queued queries when pipeline is stopped or if it fails, then the read queries under execution are cancelled, whereas the write type of queries under execution are not cancelled. Databricks internally determines which queries are safe to be cancelled and cancels those queries.
Warning: Due to an issue with DLP, aborting an ELT Pipeline validation (with preview data enabled) causes only those SQL statements that retrieve data using bind parameters to get aborted while all other static statements (that use values instead of bind parameters) persist.
  • For example, select * from a_table where id = 10 will not be aborted while select * from test where id = ? gets aborted.

To avoid this issue, ensure that you always configure your Snap settings to use bind parameters inside its SQL queries.

Default value: Continue to execute queued queries when pipeline is stopped or if it fails.

Example: Cancel queued queries when pipeline is stopped or if it fails

Snap execution Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Execute only

Example: Validate & Execute

Troubleshooting

Error Reason Resolution
Missing property value You have not specified a value for the required field where this message appears. Ensure that you specify valid values for all required fields.

Examples