In this article
The page's title should always be the Snap's name. For example, File Reader.
Use this Snap to add a WHERE clause in your SQL query. The WHERE clause is used to create filters/conditions. The Snap can also be used an an equivalent of a HAVING clause in the context of aggregate operations. This Snap also allows you to preview the result of the output query. You can validate the modified query using this preview functionality.
None.
None.
Input/Output | Type of View | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|
Input | Document |
|
| The SQL query in which you want to add the WHERE clause. |
Output | Document |
|
| The modified SQL query with the WHERE clause and the condition. |
Parameter Name | Data Type | Description | Default Value | Example |
---|---|---|---|---|
Label | String | ELT Filter | GRADE_RECORD | |
ELT Filter | String | Required. The condition for the WHERE clause. You can also use Pipeline parameters in this field to bind values. However, you must be careful to avoid SQL injection. See Preventing SQL Injection for details. | N/A | GRADE = 1 GENDER = 'MALE' |
Get preview data | Check box | Not selected | Selected |
You can pass Pipeline parameters as values in an SQL expression; however, if you do not phrase the expression properly it can lead to the parameter's name being bound as a value in the database. This potentially incorrect information being inserted into the database is known as SQL injection. It is thus necessary to take precautions when including Pipeline parameters in your SQL expression to prevent SQL injection. Based upon the intended use of the Pipeline parameter, use one or both the following methods to prevent accidental SQL injection:
You can reference the Pipeline parameter directly with a JSON-path without enabling expressions.
For example, if you want to use the Pipeline parameter, name, which contains the value of a column in the ELT Filter field:
colname = _name |
You must enable expressions when using Pipeline parameters for dynamic substitutions. Format the SQL expression, except the Pipeline parameter's reference, as a string.
For example, if you want to use the Pipeline parameter, name, which contains the value of a column in the ELT Filter field:
_columnname + “= _name” |
The Snap evaluates the expression and also carries out path substitutions.
The Snap pre-processes the query to extract any JSON-Paths and converts them to bound parameters. For example, consider the following query:
_columnname + “= _name” |
The Snap converts this query into the following before turning it into a prepared statement for the database:
colname = ? |
The Snap evaluates the JSON-Path to get the value to bind the Pipeline parameter in the prepared statement.
When expressions are disabled, use \ as an escape character to treat underscore (_) as a string. For example:
|
None.
|
Edit the Excerpt Include macro below to link to the Snap Pack page for this Snap page. Ensure that the heading Snap Pack History is not within the Snap Pack's history Excerpt.
Provide links to the endpoint's official documentation, any relevant or related internal documentation, and any other links you have referred to on this page. Care should be taken when referencing external sites/documentation that it is an official site/documentation. Do not refer to forums such as stackoverflow.