Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Overview

The Snowflake Multi Execute Snap is a Write type Snap that enables you to execute multiple queries as a single atomic unit. This means that. if any query fails in execution, the changes are rolled back. This Snap supports executing all Snowflake queries.

Expected Input and Output

While the Snap does not require an input document, it supports document input and generates document outputs. Snaps that accept or generate documents can be used upstream or downstream of the Snap.

Expected upstream Snaps:  The dynamic variables used in the execute query can be defined by providing values upstream. Document-generating Snaps such as JSON Generator can be used in upstream.
 
Expected downstream Snaps: The Snap will output one document for every record retrieved, hence any document processing Snap can be used downstream. 

Prerequisites

  • Read and write access to the Snowflake instance.
  • Insert excerpt
    Snowflake - Bulk Load
    Snowflake - Bulk Load
    nopaneltrue
  • Security Prerequisites: You should have the following permissions in your Snowflake account to execute this Snap:

    Usage (DB and Schema): Privilege to use database, role, and schema.

    Create table: Privilege to create table on database. role and schema.

    The following commands enable minimum privileges in the Snowflake Console:

Code Block
grant usage on database <database_name> to role <role_name>;
grant usage on schema <database_name>.<schema_name>;
 
grant "CREATE TABLE" on database <database_name> to role <role_name>;
grant "CREATE TABLE" on schema <database_name>.<schema_name>;

For more information on Snowflake privileges, refer to Access Control Privileges.

Internal SQL Commands

The permissions to grant for using commands depends on the queries you provide in this Snap.

Configuring Accounts

This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Snowflake Account for information on setting up this type of account.

Configuring Views

Input

This Snap has at most one document input view.
OutputThis Snap has at most one document output view.
ErrorThis Snap has at most one document error view.

Troubleshooting

None.

Support, Limitations and Known Issues

  • Select statement and transactional statements such as Begin, Commit, and Rollback are not supported. 
  • Changes made to the database using Data Definition Language (DDL) queries are not rolled back if the Snap fails, this is since DDL statements are always auto-committed by default.
    If there is one DDL query among other queries that the Snap is executing, then the rollback is only for the changes made by the queries executed after the DDL query. Ensure that the Disable session auto-commit property is selected when using DDL queries. See Snowflake Auto-commit for details. This is not applicable to Data Modification Language (DML) queries.
  • User-defined functions (UDFs) created in the Snowflake console can be executed using Snowflake - Multi Execute Snap. See Snowflake Multi Execute-Examples. 
  • The Snap may break existing Pipelines if the JDBC Driver is updated to a newer version.

    Note
    titleSnowflake Execute and Multi-Execute Snaps may break existing Pipelines if the JDBC Driver is updated to a newer version.

    With the updated JDBC driver (version 3.12.3), the Snowflake Execute and Multi-Execute Snaps' output displays a Status of "-1" instead of "0" without the Message field upon successfully executing DDL statements. If your Pipelines use these Snaps and downstream Snaps use the Status field's value from these, you must modify the downstream Snaps to proceed on a status value of -1 instead of 0.

    This change in the Snap behavior follows from the change introduced in the Snowflake JDBC driver in version 3.8.1:
    "Statement.getUpdateCount() and PreparedStatement.getUpdateCount() return the number of rows updated by DML statements. For all other types of statements, including queries, they return -1."


Modes

Snap Settings


LabelRequired. The name for the Snap. Modify this to be more specific, especially if there are more than one of the same Snap in the pipeline.
SQL Statements

Required. Provide the queries to be executed by the Snap. End each query with a semi-colon, except the last query. To add another query, click the + to add a row and there add the query. 

Default value: None

Note
titleUsing Where Clauses

Valid JSON paths that are defined in the WHERE clause for queries/statements are substituted with values from an incoming document. If the error view is enabled, documents are written to the error view if the document is missing a value to be substituted into the query/statement. 

Multiexcerpt include macro
nameME_DB_Snaps_Query_Examples
pageOracle - Update

Warning
titleSingle quotes in values must be escaped

Any relational database (RDBMS) treats single quotes (') as special symbols. So, single quotes in the data or values passed through a DML query may cause the Snap to fail when the query is executed. Ensure that you pass two consecutive single quotes in place of one within these values to escape the single quote through these queries.

For example:

If String To pass this valueUse
Has no single quotes
Schaum Series
'Schaum Series'
Contains single quotes
O'Reilly's Publication
'O''Reilly''s Publication'



Session auto-commit

Select this to enable the session's auto-commit. This is useful when using DDL queries since the changes made by such queries cannot be rolled back if the Snap/pipeline fails. If deselected, changes made by DML queries can be rolled back or changes made by DML queries after a DDL queries can be rolled back.

Default value: Selected

Use Result Query

Select this property to write the result of each of the query execution, in case of multiple queries, to Snap's output view after the successful execution. The output of the Snap will be enclosed within the key, Result Query and the value will be the actual output produced by the SQL query. 

The option would allow users to effectively track the query's execution by clearly indicating the successful executions and the number of records affected, if any, after the execution.

Manage Queued Queries

Select this property to decide whether the Snap should continue or cancel the execution of the queued Snowflake Execute SQL queries when you stop the pipeline.

Note

If you select Cancel queued queries when the Pipeline is stopped or if it fails, then the read queries under execution are canceled, whereas the write type of queries under execution is not canceled. Snowflake internally determines which queries are safe to be canceled and cancels those queries.

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

Multiexcerpt include macro
nameSnap Execution
pageSOAP Execute

Multiexcerpt include macro
nameExecution_Detail_Write
pageSOAP Execute

Examples

In the following Pipeline, Snowflake Execute Snap is used to define and execute various UDF queries and the Snowflake Multi Execute Snap is used to give process multiple Snowflake queries in a single transaction. 

First, the Snowflake Execute Snap is used to define the user-defined function in the SQL statement. RECURSION_TEST is one of the Scalar JavaScript UDF in Snowflake. 

The Snap settings and the Output view are displayed as follows:

Then, the Snowflake Multi Execute Snap is used to execute multiple Snowflake queries as a single transaction for every input document. The Snap settings and the Output view are displayed as follows:

Insert excerpt
Snowflake Snap Pack
Snowflake Snap Pack
nopaneltrue