$customHeader
Skip to end of banner
Go to start of banner

Azure Synapse SQL - Execute

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 33 Next »

In this article

Overview

You can use this Snap to execute Transact-SQL queries.

This Snap works only with single queries.

Snap Type

The Azure Synapse SQL - Execute Snap is a Write-type Snap that writes the results of the executed SQL queries.

Prerequisites

  • Valid Azure Synapse SQL Account.

  • Access to Azure Synapse SQL and the required permissions to execute T-SQL queries.

Support for Ultra Pipelines  

Works in Ultra Pipelines

Limitations

When the table name contains single quote characters, the No table found error is displayed. This is because of the JDBC driver limitation.

Known Issues

This Snap fails to insert null values for date data types, because of an issue with the jOOQ auto cast() expression in the transformed query.

Behavior Change

As part of 436patches25696, when you use a stored procedure in the Azure Synapse SQL - Execute Snap, the Snap displays Message: Success and $UPDATE_COUNT=-1, 0, or 1 (based on the Snap Pack behavior) in the output.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

  • Min: 0

  • Max: 1

  • Mapper

  • Copy

If the input view is defined, then the where clause substitutes incoming values for a specific query.

Output

Document

  • Min: 0

  • Max: 1

  • JSON Formatter

If an output view is available and an update/insert/merge/delete statement was executed, then the original document that was used to create the statement will be output with the status of the executed statement.

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

  • 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 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 ValueAzure Synapse SQL - Execute
ExampleExecute EmployRecords

String

Specify a unique name for the Snap.

SQL Statement*

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

String/Expression

Specify the SQL statement to execute on the server. We recommend you to add a single query in the SQL Statement field. There are two possible scenarios that you encounter when working with SQL statements in SnapLogic. 

Scenarios to successfully execute your SQL statements

Scenario 1: Executing SQL statements without expressions.
If the expression toggle of the SQL statement field is not selected:

  • The SQL statement must not be within quotes. 

  • The $<variable_name> parts of the SQL statement are expressions. In the below example, $id and $book.

  • email = 'you@example.com' or email = $email 

  • emp=$emp

Additionally, the JSON path is allowed only in the WHERE clause. If the SQL statement starts with SELECT (case-insensitive), the Snap regards it as a select-type query and executes once per input document. Else, it regards it as write-type query and executes in batch mode.

Scenario 2: Executing SQL queries using expressions.
If the expression toggle of the SQL statement field is selected:

  • The SQL statement must be within quotes. 

  • The + $<variable_name> + parts of the SQL statement are expressions, and must not be within quotes. In the below example, $tablename.

  • The $<variable_name> parts of the SQL statement are bind parameter, and must be within quotes. In the below example, $id and $book.

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

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

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

Do not specify Table name and column names as bind parameters. You can only provide values as bind parameters.

  • The non-expression form uses bind parameters, so it is faster than executing N arbitrary SQL expressions.

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

  • The '$' sign and identifier characters, such as double quotes (“), single quotes ('), or back quotes (`), are reserved characters and should not be used in comments or for purposes other than their originally intended purpose.

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.

Query type

Default Value: Auto
Example: Read

Dropdown list/Expression

Select the type of query for your SQL statement (Read or Write).

When Auto is selected, the Snap tries to determine the query type automatically.
If the execution result of the query is not as expected, you can change the query type to Read or Write.

Ignore empty result

Default value: Deselected

Checkbox

Select this checkbox to enable the Snap to ignore empty result and not write a document to the output view when a SELECT operation does not produce any result.
If you deselect this checkbox and with the default Pass through option, the input document is passed through to the output view.

Number of Retries

Default Value: 0
Example: 3

Integer/Expression

Specify the maximum number of retry attempts the Snap must make in case there is a network failure, and the Snap is unable to read the target file. The request is terminated if the attempts do not result in a response.

If the value is larger than 0, the Snap first downloads the target file into a temporary local file. If any error occurs during the download, the Snap waits for the time specified in the Retry interval and attempts to download the file again from the beginning. When the download is successful, the Snap streams the data from the temporary file to the downstream Pipeline. All temporary local files are deleted when they are no longer needed.

Retry Interval (Seconds)

Default Value: 1
Example: 10

Integer/Expression

Specify the time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception. 

Auto Commit

Default value: Use account setting
Example: True

Dropdown list

Select one of the following options to override the state of Auto commit on the account:

  • True - Executes with auto-commit enabled regardless of the value set for Auto commit in the Account used by the Snap.

  • False - Executes with auto-commit disabled regardless of the value set for Auto commit in the Account used by the Snap.

  • Use account setting - Executes with Auto commit property value inherited by the Account used by the Snap.

Auto Commit may be enabled for certain use cases if PostgreSQL JDBC driver is used in either Redshift, PostgreSQL or Generic JDBC Snap. But the JDBC driver may cause out of memory issues when Select statements are executed. In such cases, Auto commit in Snap should be set to False and the Fetch size in the Account settings can be increased for optimal performance.

Behavior of DML Queries in Database Execute Snap with respect to Auto Commit setting:

  • DDL queries used in the Database Execute Snap will be committed by the Database itself, regardless of the Auto-commit setting.

  • When Auto commit is set to false for the DML queries, the commit is called at the end of the Snap's execution.

  • The Auto commit needs to be true in a scenario where the downstream Snap does depend on the data processed on an Upstream Database Execute Snap containing a DML query.

  • When the Auto commit is set to the Use account setting on the Snap, the account level commit needs to be enabled.

Snap Execution

Default ValueValidate & Execute
Example: Execute only

Dropdown list

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

Troubleshooting

Error

Reason

Resolution

Implicit conversion from data type varbinary to date is not allowed.

This error is because of an issue with the jOOQ auto cast() expression in the transformed query.

Use the CONCAT reference for each value to run the query.

Example

Fetching Employee Records from the Employee Table

This example Pipeline demonstrates how to fetch employee records from the Employee table.

Step 1: Configure the Azure Synapse SQL - Execute Snap with a SELECT query that reads all employee records from the “dbo.Employee” table.

On validation, this Snap generates the output that lists all the objects associated with Employee records.

Step 2: Configure the JSON Formatter Snap to read the input document and generate binary output.

Step 3: Configure the File Writer Snap to write the employee.json file into the SL database.

On validation, the employee.json file is generated:

Download this Pipeline

Downloads

  1. Download and import the Pipeline into SnapLogic.

  2. Configure Snap accounts as applicable.

  3. Provide Pipeline parameters as applicable.

  File Modified
You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.
No files shared here yet.
  • Drag and drop to upload or browse for files
  • Snap Pack History

     Click here to expand...

    Release

    Snap Pack Version

    Date

    Type

    Updates

    May 2024

    437patches26597

    Latest

    Fixed an issue with the Azure Synapse SQL Select Snap that displayed an error and did not retry the connection when the serverless SQL pool was warming up.

    May 2024

    main26341

    Stable

    February 2024

    436patches25597

    -

    Upgraded the jOOQ library of the Azure Synapse SQL Snap Pack from v3.9.1 to v3.17.x.

    This upgrade is currently NOT available with the latest distribution. However, you can still consume this patch through 436patches25597. This update is scheduled to be included in the latest distribution release on April 10, 2024, and will be a part of the stable distribution with the GA release on May 8. 2024.

    Behavior change:

    The jOOQ library upgrade for Azure Synapse SQL Snap Pack, done as part of the 436patches25597, resulted in the following behavior change:

    Previously, when “null”(string) was passed from the upstream Mapper Snap for the Bigint datatype, the Azure Synapse SQL Update Snap updated it as null without displaying any error. It displayed the status as 0 and the output message as Success. Now, the Snap displays the following error in this scenario:

    Error converting value(expecting a number but you are sending String(“null”))

    If you pass null from Mapper Snap with the expression enabled, the Snap updates the null value for the BigInt datatype correctly, as earlier.

    February 2024

    main25112

    Stable

    Updated and certified against the current SnapLogic Platform release.

    November 2023

    main23721

    Stable

    Updated and certified against the current SnapLogic Platform release.

    August 2023

    main22460

    Stable

    The Azure Synapse SQL - Execute Snap now includes a new Query type field. When Auto is selected, the Snap tries to determine the query type automatically.

    May 2023

    433patches21718

    Latest

    Fixed an issue with the Azure Synapse SQL Bulkload Snap that caused a 404 error when the External Location was set to ADLS Gen2 and the Azure Folder field was not specified in the account settings.

    May 2023

    main21015

    Stable

    Upgraded with the latest SnapLogic Platform release.

    February 2023

    432patches20389

    Latest

    The Azure Synapse SQL Account and Azure Synapse SQL Active Directory Account now support the latest JDBC Driver 12.2.0.jre11 by default. You do not have to upload the JAR file in the JDBC Driver field manually.

    February 2023

    main19844

     

    Stable

    Upgraded with the latest SnapLogic Platform release.

    November 2022

    431patches19493

    Latest

    The Azure Synapse SQL - Bulk Load Snap no longer fails when loading the JDBC driver from SLDB as it now uses the uploaded JAR driver when performing all bulk load operations.

    November 2022

    431patches19410

    Stable

    Fixed the Azure SQL - Execute Snap using the Azure SQL Active Directory Account that failed with SQL operation failed errors in environments using federated authentication

    November 2022

    431patches19410

    Latest

    Fixed the Azure SQL - Execute Snap using the Azure SQL Active Directory Account that failed with SQL operation failed errors in environments using federated authentication

    November 2022

    431patches19354

    Latest

    The Azure Synapse SQL - Bulk Load Snap no longer fails with the error Invalid column value in CSV data file when the data contains the field quote character (").

    November 2022

    431patches19263

    Latest

    The Azure Synapse SQL Insert Snap no longer supports the Preserve Case Sensitivity checkbox.

    November 2022

    main18944

    Stable

    Introduced the Azure Synapse SQL Snap Pack. The Azure Synapse Analytics is service from Microsoft that helps you query data to create, update, insert, or delete data in the Azure Synapse SQL. This Snap Pack contains the following Snaps:


    Related Content

    • No labels