Snowflake - Select

On this Page

Overview

You can use this Snap to fetch data from a database by providing a table name and configuring the Snowflake connection. The Snap produces the records from the database on its output view which can then be processed by a downstream Snap. 

JSON paths can be used in a query, and values from an incoming document will be substituted into the query. However, documents missing values for a given JSON path will be written to Snap's error view. After a query is executed, the query's results are merged into the incoming document, overwriting any existing keys' values. If there are no results from the query, the original document is output.

snowflake-select-overview.png

Snap Type

The Snowflake - Select Snap is a Read-type Snap that enables you to format the WHERE clause from the input document stream for a SQL Server query. 

Prerequisites

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.

The following commands enable minimum privileges in the Snowflake Console:

grant usage on database <database_name> to role <role_name>; grant usage on schema <database_name>.<schema_name>;

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

Internal SQL Commands

This Snap uses the SELECT command internally. It enables you to query the database and retrieve a set of rows.

Support for Ultra Pipelines

Works in Ultra Pipelines. However, we recommend that you not use this Snap in an Ultra Pipeline.

Known Issues

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.

Behavior Change

From 4.30 Release, the Snowflake - Select Snap writes the output value as-is for FLOAT or DOUBLE datatype columns if these columns have the value as NaN (Not a Number). Earlier, the Snap displayed an exception error when the FLOAT or DOUBLE datatype column has the value as NaN. This behavior is not backward compatible.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input

Document

  • Min: 0

  • Max: 1

  • Mapper

  • Binary to Document

A document that provides values for one or more properties of the Snap or for pass-through purpose. 

A dynamic where clause can be defined by providing values upstream. As the Mapper Snap can provide constants, pipeline parameters mapped into variables then can be used in the where clause or even in the table/schema properties. 

Output

Document

  • Min: 1

  • Max: 2

  • Mapper

  • Snowflake Execute

This Snap has one document output view by default. A second view can be added to show the metadata for the table as a Document. The metadata document can then be fed into the second input view of Snowflake - Insert or Bulk Load Snaps so that the table is created in Snowflake with a similar schema as the source table. The Snap will output one document for every record retrieved, hence any document processing Snap can be used downstream. 

Document for each record retrieved. Special types such as TIMESTAMP, TIME are converted into SnapLogic internal date type representations which then can be consumed by downstream Snaps just like any other data type.

Queries produced by the Snap have an equivalent format:

SELECT * FROM [table] WHERE [where clause] ORDER BY [ordering] LIMIT [limit] OFFSET [offset]

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 if 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 (): Indicates a list that is dynamically populated based on the configuration.

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

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

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

Field Name

Field Type

Description

Label*


Default ValueSnowflake - Select
Example: Load Employee Tables

String

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

Schema Name

 

Default Value: N/A
Example: schema_demo

String/Expression

The database schema name. In case it is not defined, then the suggestion for the Table Name will retrieve all table names of all schemas. The property is suggestible and will retrieve available database schemas during suggest values.

Table Name*

 

Default Value: N/A
Example: employees_table

String/Expression

Specify the table to execute the select query on.

Where Clause 

 

Default Value: N/A
Example: ID in (48,50)

String/Expression

Specify the where clause of the SELECT statement. This supports document value substitution (such as $person.firstname will be substituted with the value found in the incoming document at the path).

Order By 

Use this fieldset to specify the columns in the order in which you want to sort the database. The default database sort order will be used.

Column Names

 

Default Value: N/A
Example: email

String/Expression

Specify the column names.

Time travel props

Use this field set to configure the time travel clause.

Key column

 

Default Value: At Offset
Example: Before Offset

Dropdown list

Choose the key column for the query. The available options are:

  • At Offset

  • Before Statement

  • At Statement

  • Before Timestamp

  • At Timestamp

  • Before Offset

Learn more about the time travel properties.

Value column

Default Value: N/A
Example: -60*5

String/Expression

Specify the value for the corresponding key column.

Limit offset

 

Default Value: N/A
Example: 0

Integer/Expression

Specify the offset for the limit clause. This is where the result set should start.

Limit rows 

 

Default Value: N/A
Example: 10

Integer/Expression

Specify the number of rows to return from the query.

Output fields

 

Default Value: N/A

Example: email,

String/Expression

Enter or select output fields for Snowflake SQL SELECT statement. To select all fields, leave it at default. 

Fetch Output Fields In Schema

 

Default Value: Deselected

Checkbox

Select this check box to include only the selected fields or columns in the Output Schema (second output view). If you do not provide any Output fields, all the columns are visible in the output.
If you provide output fields, we recommend you to select Fetch Output Fields In Schema check box.

 

Pass-through 

 

Default Value: Selected

Checkbox

Select to make the input document will be pass through the output view under the key 'original'. 

 

Ignore empty result

 

Default Value: Deselected

Checkbox

Select if you want no document to be written to the output view when a SELECT operation does not produce any result. If this property is not selected and the Pass-through property is selected, the input document will be passed through to the output view.

Match data types

 

Default Value: Deselected

Checkbox

Conditional. This field applies only when the Output fields field is provided with any values.

If this checkbox is selected, the Snap tries to match the output data types the same as when the Output fields property is empty (SELECT * FROM ...). The output preview would be in the same format as the one when SELECT * FROM is implied and all the contents of the table are displayed.

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.

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.

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

Minimum value: 0

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.



Staging mode

 

Dropdown list

Required when the value in the Number of retries field is greater than 0. 

Specify the location from the following options to store input documents between retries:

  • In memory: The query results are stored in the Snaplex memory. If the query is too large to fit in the memory space, it may cause the Snap to fail, choose the On disk option.

  • On disk: The query results are stored on the disk in a temporary (tmp) directory that is managed by the SnapLogic platform. This directory is deleted automatically when the Snap terminates.

Handle Timestamp and Date Time Data

 

Default Value: Default Date Time format in UTC Time Zone
Example: SnapLogic Date Time format in Regional Time Zone

Dropdown list/Expression

Specify how the Snap must handle timestamp and date time data. The available options are:

  • Default Date Time format in UTC Time Zone: The Snowflake date time data are represented in UTC Time Zone.

  • SnapLogic Date Time format in Regional Time Zone: The Snowflake date time data are represented in the same regional time zone value, as provided in the Snowflake account.

Manage Queued Queries

 

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

Dropdown list

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

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

Snap Execution

 

Default Value: Validate & Execute
Example: Execute only

Dropdown list

Select one of the following three modes in which the Snap executes:

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

Examples

Read a Table from Snowflake

The following example demonstrates how to read table data using the Snowflake - Select Snap. 

The above Snap reads test@test table data, and orders the results based on the C1 column. Additionally, it limits the results to only 10 rows. 

Successful execution of the Pipelines gives the following output in the preview: 

Snap Pack History