Snowflake Query

Use this activity to run a simple or a complex SQL query on a Snowflake domain. The Snowflake Query activity returns information in the form of rows.

Settings

The Settings tab has the following field:

Field Description
Snowflake Connection Name of the Snowflake connection.

Input Settings

The Input Settings tab has the following fields:

Field Description
Query

An SQL statement used to query the database. The query can be a simple query or a complex query. A complex query has nested SQL statements. Prepared SQL queries can be constructed by using substitution variables or substitution parameters of the form ?<fieldname> in the query statement.

Example:

 select * from student where name like ?name; 
					 

Each substitution variable identifies an input parameter whose mapped value is substituted into the substitution variable at runtime. The substitution variable can be reused for the same input parameter elsewhere in the query. Input parameters used in the WHERE clause, output parameters used in the SELECT clause, and their corresponding type information is automatically fetched from the database using the selected connection for the entered query. Input and output fields on the Input and Output tabs of the activity are also automatically generated. You must include the semicolon (;) at the end of the query. To indicate the end of the query, a semicolon is expected at the end. A missing semicolon at the end of the query causes the query to be unresponsive.

Examples of simple and complex queries:

Simple query

SELECT * FROM employee; 

In this query, the output fields are generated from the table employee's column information.

SELECT description, url, name FROM webpages
WHERE name = ?name and id > ?id ORDER BY name;

For this query, output fields are generated for description, url, and name. Input fields are generated for name (varchar) and id (numeric). Also, the mapped values for the name and id fields are substituted into the ?name and ?id substitution variables at runtime.

Nested query

SELECT firstname, lastname, total_quantity
FROM (SELECT buyerid, sum(qtysold) total_quantity
FROM sales
GROUP BY buyerid
ORDER BY total_quantity desc limit 10) Q, users
WHERE Q.buyerid = userid
ORDER BY Q.total_quantity desc;
Manually Configure Metadata Set the Manually Configure Metadata field to true to fetch table metadata manually. For more information, see Using Manually Configure Metadata Option.
Table Schema

Displays the metadata of the SQL Query statement. You can modify the column metadata if Manually Configure Metadata is set to true.

Note: If you modify the metadata, ensure that it is in agreement with the query added.

Input

The Input tab contains the input schema in a tree structure format. The fields that were selected in the Input Settings tab are available in the schema. You can either hard code their values or map them to a field from the output of a preceding activity in the flow by using the Mapper.

Output

The Output tab displays the output schema of the activity as a tree structure. The output is read-only. The information in the schema varies based on the fields selected on the Input Settings tab. The properties that are displayed in the schema correspond to the output of this activity and can be used as input by subsequent activities in the flow.