Versions Compared

Key

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

...

Multiexcerpt macro
hiddenfalse
nameRedshift limitation with PostgreSQL driver
fallbackfalse
note

If you use the PostgreSQL driver (org.postgresql.Driver) with the Redshift Snap Pack, it could result in errors if the data type provided to the Snap does not match the data type in the Redshift table schema. Either use the Redshift driver (com.amazon.redshift.jdbc42.Driver) or use the correct data type in the input document to resolve these errors.

If you use the PostgreSQL driver (org.postgresql.Driver) with the Redshift Snap Pack, it could result in errors if the data type provided to the Snap does not match the data type in the Redshift table schema. Either use the Redshift driver (com.amazon.redshift.jdbc42.Driver) or use the correct data type in the input document to resolve these errors.

  • When the SQL statement property is an expression, the pipeline parameters are shown in the suggest, but not the input schema.

  • Multiple queries might not work, because the underlying JDBC driver does not support multiple queries. We recommend you to use the Redshift - Multi Execute Snap for running multiple queries.

...

Multiexcerpt include macro
nameBehavior change in Database Execute Snaps
pageAzure SQL - Execute

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input 

Document

  • Min: 0

  • Max: 1

  • Mapper

  • JSON Generator

A Snap that can contain data that is to be used with the JSON paths defined in the SQL, if any, or to be passed through.

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

  • Mapper

A document with the result set output, if any, and update count as return status from the Redshift SQL. The Snap output all records of a batch (as configured in your account settings) to the error view if the write fails during batch processing.

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

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 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 Value: Redshift - Execute
Example: Redshift - Execute

String

Specify the name for the Snap.

SQL statement*


Default Value: N/A
Example: "SELECT""EMPNO=$EMPNO and ENAME=$EMPNAME"

String/Expression

Specify the SQL statement to execute on the server. 

  • Redshift allows using \ (backslash) or ' (single quote) to escape special characters in the SQL. Therefore, we recommend that you use ' (single quote) in the SQL statement to escape special characters .

  • We recommend you to add a single query in the SQL Statement field.

Note

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

If ‘$' is not part of the JSON path, it can be escaped by writing it as \$ so that it can be executed as-is. For example, SELECT \$2, \$3 FROM mytable. If the character before $ is alphanumeric, then '$' does not have to be escaped. (for instance, SELECT metadata$filename ...)

Following is an example of the procedure:

CREATE OR REPLACE PROCEDURE sp_inout_proc (INOUT a int, b int, INOUT c int)
AS \$\$
BEGIN
a := b * a;
c := b * c;
END;
\$\$

Panel
bgColor#DEEBFF
  • If a SELECT query is executed, the query results are merged into the incoming document and any the values of the existing keys are overwritten. If there are no results from the query, the original document is written. 

  • If the SQL is parameterized (having valid JSON paths defined in the SQL text), the Snap creates a prepared statement and binds any parameters with the substituted values from the incoming document before executing in batch. If the SQL is not parameterized (literal SQL text), it will not create a PREPARE statement and instead execute SQL as a single query instead of batching. Learn more about executing SQL statements.

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.

Pass through


Default Value: Selected

Checkbox

Select this checkbox to pass the input document through to the output view under the key 'original'. This property applies only to the Execute Snaps with SELECT statement.

Ignore empty result


Default Value: Deselected

Checkbox

Select this checkbox to ignore empty result; no document will be written to the output view when a SELECT operation does not produce any result.
If you deselect this checkbox and select the Pass through checkbox, the input document will be passed through to the output view.

Number of retries

Default Value: 0
Example: 3

Integer/Expression

Specify the maximum number of attempts to be made to receive a response. The request is terminated if the attempts do not result in a response.

Ensure that the local drive has sufficient free disk space to store the temporary local file.

Retry interval (seconds)

Default Value: 1
Example: 10

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:

  • True: The Snap enables the auto-commit. The value set on this field overrides the Auto commit property set at the account level.

  • False: The Snap disables the auto-commit. The value set on this field overrides the Auto commit property set at the account level.

  • Use account setting: The Snap uses the Auto commit value set in the Account. When you select this option, you must enable the Auto commit option in the account settings.

Note

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. For such cases, we recommend you to set Auto commit in the Snap settings to False and the Fetch size in the Account settings can be increased for optimal performance.

Behavior of DML Queries in the Execute Snap when auto-commit is false

  • DDL queries used in the Execute Snap is 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 must be true in a scenario where the downstream Snap does depend on the data processed on an upstream Snap containing a DML query.

Snap Execution


Default Value: Execute only
Example: Validate & Execute

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

type "e" does not exist

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.

...

Additional Information

Scenarios to successfully execute your SQL statements

...

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 value

Use

Has no single quotes

Schaum Series

'Schaum Series'

Contains single quotes

O'Reilly's Publication

'O''Reilly''s Publication'

Recommendations

  • Be cautious when running your queries, because you can drop your database and lock tables while executing SQL statements.

  • Running multiple queries might not work with the Redshift - Execute Snap. If you need to run multiple queries, we recommend you to use the Redshift -Multi Execute Snap.

...