Provide CQL queries in mappings

In the Pulsar topic mapping, you can optionally provide a CQL query that should run when the new record arrives on the Pulsar topic.

This feature is only meant for advanced use cases. Most often, you can use the standard Pulsar mapping without a query. If you define a query in the topic-to-table mapping, the query has priority and will be used instead of the automatically generated action.

If used, you must provide the bound variables used in the query in the mapping column. For example, give the following query:

topic:
  my_topic:
    my_ks:
      my_table:
        query: 'INSERT INTO %s.types (bigintCol, intCol) VALUES (:some_name, :some_name_2)'

The corresponding mapping in this example should be defined as:

topic:
  my_topic:
    my_ks:
      my_table:
        mapping: 'some_name=value.bigint, some_name_2=value.int'

Additional examples of CQL queries that you could include with the topic-to-table mapping:

topic:
  my_topic:
    my_ks:
      my_table:
        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;'

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000, info@datastax.com