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

...

You can use this Snap to execute multiple queries

...

. If any query fails in execution, the changes are rolled back.

...

The Snowflake - Multi Execute Snap supports executing all Snowflake queries and does only write operations.

Image Removed

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.

...

Snap Type

The Snowflake - Multi Execute is a Write type Snap.

Prerequisites

  • Read and write access to the Snowflake instance.

  • Insert excerpt
    Snowflake - Bulk Load
    Snowflake - Bulk Load
    nopaneltrue

Security Prerequisites

...

You must 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>;

...

Learn more

...

about Snowflake privileges

...

Access Control Privileges.

Internal SQL Commands

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

Support for Ultra Pipelines

Does not Work in Ultra Pipelines.

...

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

...

Troubleshooting

None.

...

 

Limitations and Known Issues

  • The Snap may fail due to an error when the batch size specified in the account is 1 and the number of rows updated by an executed query exceeds 2.1 billion.

  • Because of performance issues, all Snowflake Snaps now ignore the Cancel queued queries when pipeline is stopped or if it fails option for Manage Queued Queries, even when selected. Snaps behave as though the default Continue to execute queued queries when the Pipeline is stopped or if it fails option were selected.

...

  • Select statement and transactional statements such as Begin, Commit, and Rollback are not supported. 

  • Changes made to the database

...

...

  •  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.

...

...

  •  for details. This is not applicable

...

...

  •  queries.

  • User-defined functions (UDFs) created in the Snowflake console can be executed

...

  • using Snowflake - Multi Execute Snap.

...

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

...

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

  • Min: 0

  • Max: 1

  • Mapper

  • Copy

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.

Output

Document

 

  • Min: 0

  • Max: 1

  • JSON Formatter

The Snap will output one document for every record retrieved, hence any document processing Snap can be used downstream. 

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:

  • Stop Pipeline Execution: Stops the current Pipeline execution when the Snap encounters an error.

  • 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

Info
  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon ((blue star)): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon ((blue star)): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon ((blue star)): Indicates that you can add fields in the field set.

  • Remove icon ((blue star)): Indicates that you can remove fields from the field set.

Field Name

Field Type

Description

Label*

Default ValueSnowflake - Update
Example: Load Employee Tables

String

Specify a unique name for the Snap. You can modify this to be more appropriate, especially if you have more than one of the same Snap in

...

your pipeline.

SQL Statements

...

*

Default Value: N/A

Example: INSERT into SnapLogic.book (id, book) VALUES ($id,$book)

String/Expression

Specify the Snowflake SQL statement to execute on the server. 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

...

Using 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. 

Without using expressions

  • EmpId = 12 

  • email = 

...

Multiexcerpt include macro
nameME_DB_Snaps_Query_Examples
pageOracle - Update

...

  • 'you@example.com'

Using expressions

  • "EMPNO=$EMPNO and ENAME=$EMPNAME"

  • email = $email 

  • emp=$emp

  • "emp='" + $emp + "'"

  • "EMPNO=" + $EMPNO + " and ENAME='" + $EMPNAME+ "'"

Note

Using expressions that join strings together to create SQL queries or conditions has a potential SQL injection risk and is hence unsafe. Ensure that you understand all implications and risks involved before using concatenation of strings with '=' Expression enabled. 

Info

Single 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

Default Value: Selected

Checkbox

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.

Use Result Query

Default

...

Value:

...

Deselected

...

Checkbox

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

Default Value: Continue to execute queued queries when pipeline is stopped or if it fails
Example: Cancel queued queries when the Pipeline is stopped or if it fails

Drowpdown list

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.

...

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.

...

Multiexcerpt include macro
nameSnap Execution
pageSOAP Execute

Default Value: Execute only
Example: Validate & Execute

Drowpdown list

Multiexcerpt include macro
nameExecution_Detail_Write
pageSOAP Execute

Examples

...

Processing Multiple Queries in a Single Transaction

The following example pipeline demonstrates how to process multiple Snowflake queries in a single transaction.  

Image Removed

...

Step 1: Configure the Snowflake Execute Snap

...

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:

Image Removed

Image Removed

...

Step 2: Configure the Snowflake Multi Execute Snap

...

as follows:

...

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

...

Image Removed

Image Removed

...

...

Snap Pack History

Expand

Insert excerpt
Snowflake Snap Pack
Snowflake Snap Pack
nameSnowflake_SPH
nopaneltrue

Related Content

...