On this Page
Table of Contents | ||||
---|---|---|---|---|
|
Snap Type: | Write | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description: | This Snap is used to execute multiple Redshift SQL statements sequentially inside of a single BEGIN and END transaction for each input document. If an SQL statement fails, subsequent SQL statements are not executed and error output goes to the error view (if the corresponding option is selected). If all statements are successful, all output results go to the output view. Data can be written to both output and error view if using multiple input documents. Use this Snap to perform updates to Redshift data that would otherwise be done in a Stored Procedure.
ETL Transformations & Data Flow
The Snap executes a sequence of multiple Redshift DDL commands in a sequential order as specified in the Executions section and the result will be written to the output view which contains results from individual queries that have been executed from the provided properties. If any submitted query fails, the Snap will throw an exception and rollback changes from prior queries. Input & Output:
Upstream & Downstream Snaps
| ||||||||||||||||||||||||||||||||
Prerequisites: | None | ||||||||||||||||||||||||||||||||
Limitations and Known Issues: |
| ||||||||||||||||||||||||||||||||
Configurations: | Account & AccessThis Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Redshift Account for information on setting up this type of account. Views
| ||||||||||||||||||||||||||||||||
Troubleshooting: | [None] | ||||||||||||||||||||||||||||||||
Settings | |||||||||||||||||||||||||||||||||
Label | Required. The name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline. | ||||||||||||||||||||||||||||||||
Executions | Required. Specifies the SQL statement to execute on the server. Examples:
Default value: [None] | ||||||||||||||||||||||||||||||||
|
|
Troubleshooting
Error | Reason | Resolution |
---|---|---|
| This issue occurs due to incompatibilities with the recent upgrade in the Postgres JDBC drivers. | Download the latest 4.1 Amazon Redshift driver here and use this driver in your Redshift Account configuration and retry running the Pipeline. |
Examples
Basic Use Case
The following pipeline describes how the Snap functions as a standalone Snap in a pipeline (a Select Snap is used here to display the output preview of the records added as displayed in the second image below):
An example of MultiExecute properties, in this case, the SQL is using expressions:
The successful output after two input documents:
The error output preview:
Typical Snap Configurations
The key configuration of the Snap lies in how you pass the SQL statement to execute a function:
- Without Expression: Directly passing the required SQL statements in the Redshift Multi Execute Snap. Literal statements (without SQL parameters or SnapLogic expressions):
- With SQL parameters:
With Expressions
It is possible to pass values to the Redshift Multi Execute Snap using expression language as well. In the example below, the values are passed using a query from an upstream snap and pipeline parameters. Both these methods are demonstrated in detail below:
Query from an upstream Snap: The Redshift Multi Execute Snap receives values from the upstream JSON Generator Snap.
The Multi Execute Snap executes the SQL statements as passed using the upstream JSON Generator Snap:
The Redshift Select Snap displays the out preview with the added records:
- Pipeline Parameter: Pipeline parameter set to pass the required SQL Statement to the Multi Execute Snap.
In the below Snap Executions settings, the values for the fields are passed using the pipeline parameters.
Advanced Use Case
The pipeline shows how to execute multiple SQL statements to insert records into the table, emp_RS, using the Redshift Multi Execute Snap. We also use the Redshift Select Snap to read the table to which the records are added. Here, we pass the values using the upstream and also dynamically, by defining the pipeline parameters respectively.
1. Edit the JSON Generator Snap and input the upstream data to be passed into the table, emp_RS.
The output preview from the JSON Generator Snap is as below:
2. Set the pipeline parameters to be passed dynamically:
3. In the Redshift - Multi Execute Snap, the SQL statement executions are as below:
4. The output preview of the Redshift - Multi Execute Snap has the status of the executions (result) displayed sequentially between the 'BEGIN' and the 'END' execution transaction:
5. View the table "public"."emp_RS" to which we added the records using the Redshift - Select Snap:
6. Successful execution of the pipeline displays the below output preview in a JSON or a Table format respectively:
Downloads
Multiexcerpt include macro | ||||
---|---|---|---|---|
|
Attachments | ||
---|---|---|
|
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|