Use CQL queries in mappings
In your connector configuration, you can provide a CQL query to run when a new record arrives on the Pulsar topic.
If you define a query in the mapping, the query has priority, and it is used instead of the connector’s automatically generated action. This is an advanced feature for specific use cases. Typically, you can use the standard Pulsar mapping without a query. |
If you set query
, you must provide the bound variables used in the query in the mapping column.
In the following example, notice that the bound variables, :some_name
and :some_name_2
, are included in the mapping
:
topic:
topic_name:
keyspace_name:
table_name:
query: 'INSERT INTO %s.types (bigintCol, intCol) VALUES (:some_name, :some_name_2)'
mapping: 'some_name=value.bigint, some_name_2=value.int'
Here are some additional examples of possible CQL queries that you could include in your connector configuration:
query: 'INSERT INTO ks.tbl(pkey,ccol,x) VALUES :pkey, :ccol, :x);'
query: 'INSERT INTO ks.tbl(pkey,ccol,x) VALUES (:pkey, :ccol, :x) USING TTL :input_ttl'
query: 'INSERT INTO ks.tbl(pkey,ccol,x) VALUES (:pkey, :ccol, :x) USING TIMESTAMP :input_ts'
query: 'UPDATE ks.tbl SET somelist = somelist + [:newitem] WHERE pkey = :pkey'
query: 'DELETE FROM ks.tbl WHERE pkey = :pkey AND ccol = :ccol;'
query: 'DELETE FROM ks.tbl WHERE pkey = :pkey AND ccol > :ccol1 AND ccol <= :ccol2;'
You can use CQL queries in mappings to selectively update UDTs and maps. |