Perform Cassandra Query Assertion

The Perform Cassandra Query assertion allows you to write and save a CQL (Cassandra Query Language) prepared statement for querying an external data source using a Cassandra connection. This assertion supports Batch statements, allowing you to group multiple DML (Data Modification Language) statements (INSERT, UPDATE, DELETE) into a single logical operation. This saves network exchanges between the client/server and server coordinator/replica.
gateway91
The
Perform Cassandra Query
assertion allows you to write and save a CQL (Cassandra Query Language) prepared statement for querying an external data source using a Cassandra connection. This assertion supports Batch statements, allowing you to group multiple DML (Data Modification Language) statements (INSERT, UPDATE, DELETE) into a single logical operation. This saves network exchanges between the client/server and server coordinator/replica.
This assertion supports Cassandra 2.1.2 and CQL3.
Prerequisite:
Context Variables
This assertion sets the following context variables:
Variable
Description
<prefix>
.queryresult.count
Contains the number of rows returned. If no results are returns, then this variable contains '0'.
<prefix>
.xmlResult
Contains the Cassandra query result in XML form. Set only if the "Generate XML Result" option is selected in the assertion.
<prefix>.<variable name>
When Context Variables Naming is configured, columns from the Cassandra Query result are stored in the mapped context variable.
Cluster Properties
Properties
Setting
What you should know...
Cassandra Connection
These connections are defined using the Manage Cassandra Connections task.
Query Timeout
The Cassandra query timeout, in seconds. A value of '0' means to never time out.
Query statement box
Enter the Cassandra query statements here, in CQL3. You can include context variables that will be interpreted as parameters for the prepared statement.
Note:
  • Only specific context variable types can be used.
  • Context variables of type 'Message' are not supported.
  • Simple text substitution is not supported. For example, it is not possible to inject a whole or part of a Cassandra query using context variables, due to potential injection attacks.
Test
This tests whether a CQL query is valid based on the selected connection. Be aware of these important notes before testing:
  • Query commands affect the underlying database, even in test mode. Therefore, any non-select query could irrevocably destroy data or the database structure.
  • Context variables are not supported during testing.
Context Variable Naming
This is the mapping between Cassandra columns that are returned from the query and the context variables set in the policy. For example, you map the Cassandra result set column name "id" to the variable name cassandraQuery.identifier (where "cassandraQuery" is the variable prefix).
When mapping is configured, the corresponding context variable name replaces the Cassandra result set column name. When mapping is not enabled, the original column name is used.
The maximum number of records returned by the query
The value is initially set to the
cassandra.maxRecords
cluster property, which has a default of
10
.
Query Fetch Size
The number of records in a page that is returned in one round trip to the Cassandra server. Changing the value allows you to set a different fetch size for this query.
This value is initially set to the
cassandra.fetchSize
cluster property, which has a default of
5000
.
Fail assertion if there are no results returned by the query
When set, assertion fails only if a select query returns an empty result set. Other queries (such as INSERT, UPDATE, DELETE, and other DDL statements) are not affected by this setting.
Generate XML Result
When set, the result set returned by the Cassandra server is converted to XML and placed in the
<prefix>
.xmlResult variable.
The root element is cassandraQueryResult, while the XML namespace is L7j.
Context Variable Data Types
The following mappings show which context variable data type should be used for each of the Cassandra data types:
For Cassandra data type...
Use context variable of type...
ASCII
String
BIGINT
String
BLOB
String
COUNTER
String
DECIMAL
String
DOUBLE
String
INT
Integer or String
TEXT
String
TIMESTAMP
Date/Time
TIMEUUID
String
UUID
String
VARCHAR
String
VARINT
String
You cannot use context variables for any Cassandra data type not listed in the above table.
 
Frequently Asked Questions
Question
Answer
Why are no connections visible in the drop-down list?
You must first define a connection using the Manage Cassandra Connections task.
Why must I specify a variable prefix?
This helps create unique variable names and prevents variables from overwriting each other when an assertion appears more than once in a policy.
Why did the assertion succeed even though no results were returned.
Verify that: (1) The "Fail assertion..." check box is selected. (2) You have used a "select" query command. Other commands will not fail the assertion when no results are returned.