Versions Compared

Key

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

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

Snap type:

Write


Description:

This Snap allows you to execute arbitrary Cassandra query language (CQL) supported by JDBC.

Info

This Snap works only with single queries.


Note

You can drop your database with it, so be careful.


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

If a select query is executed, the query's results are merged into the incoming document and any existing keys will have their values overwritten. On the other hand, the original document is written if there are no results from the query.

  • Expected upstream Snaps: Snaps that will either input data into Cassandra Execute, merge information with Cassandra, or required to precede execution before Cassandra execution.
  • Expected downstream Snaps: Snaps that will use information gained from Cassandra or that is dependent on Cassandra having executed prior.

Multiexcerpt include macro
nameCassKI1
pageCassandra Snap Pack

Note
The Cassandra Execute Snap is for simple DML (SELECT, INSERT, UPDATE, DELETE) type statements. 


Prerequisites:

Validated Cassandra account, verified network connectivity to Cassandra server and port, and the Cassandra server running.

Support and limitations:
  • Works in Ultra Task Pipelines.
  • The Cassandra-Execute Snap using Apache Cassandra V3 does not support $$ as an escape character for enclosing string input, as $ is a reserved character for variable substitution in SnapLogic.
  • The Cassandra Snap Pack does not support the following data types introduced in Apache Cassandra V3.x, as the underlying SnapLogic JDBC driver is designed to work with Apache Cassandra V2.1:

    • DateRange

    • Duration

    • Geo-spatial data types such as Point, Polygon and LineString

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

This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See Configuring Cassandra Accounts for information on setting up this type of account.

Views:


InputThis Snap has at most one document input view. If the input view is defined, then the where clause can substitute incoming values for a given expression.
OutputThis Snap has at most one document output view. 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 statement executed.
Error

This Snap has at most one document error view and produces zero or more documents in the view.
Note: Database write Snaps output all records of a batch (as configured in your account settings) to the error view if the write fails during batch processing.


Settings

Label


Required. 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.
SQL statement

Required. Specifies the SQL statement to execute on the server.

Info

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

Cassandra Snaps do not support batch operations, which is why this field does not support SQL bind variables in it. There are two possible scenarios that you encounter when working with SQL statements in SnapLogic. You must understand the following 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.

Examples:



Multiexcerpt include macro
nameME_DB_Execute_Snaps_Scenario1
pageAzure SQL - Execute

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. If not, it regards it as write-type query and executes in batch mode.

Scenario 2: Executing SQL queries with 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.

Examples:

 
 

Multiexcerpt include macro
nameME_DB_Execute_Snaps_Scenario2
pageAzure SQL - Execute

Warning
titleCaution

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. 


Warning
titleSingle 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.

For example:

If String To pass this valueUse
Has no single quotes
Schaum Series
'Schaum Series'
Contains single quotes
O'Reilly's Publication
'O''Reilly''s Publication'



Known issue: When the SQL statement property is an expression, the Pipeline parameters are shown in the suggest, but not the input schema. 

Default value: [None] 

This Snap does not allow you to inject SQL, such as select * from people where $columnName = "abc".

Only values can be substituted since it uses prepared statements for execution, which, for example, results in select * from people where address = ?.

Note

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.


Query type

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.

Default Value: Auto
Example: Read

Pass through 


If checked, the input document will be passed through to the output view under the key 'original'. This property applies only to the Execute Snaps with SELECT statement.

Default value: True

Ignore empty result 


If selected, no document will 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.
Default value: Not selected

Number of retries

Number of times that SnapLogic tries the process before displaying an error.

Multiexcerpt include macro
nameretries
pageFile Reader

Retry interval (seconds)Number of seconds between retries.

Multiexcerpt include macro
nameSnap Execution
pageSOAP Execute

Multiexcerpt include macro
nameExecution_Detail_Write
pageSOAP Execute

 
 

Troubleshooting


  • Run Cassandra JDBC driver using another JDBC tool to verify syntax and results.

Example


Insert excerpt
Cassandra Snap Pack
Cassandra Snap Pack
nopaneltrue