The now() function in mappings

In the Apache Pulsar™ topic mapping, you can use the now()function. It returns TIMEUUID, which is documented in the UUID and timeuuid column.

For example:

topic:
  my_topic:
    my_ks:
      my_table:
        mapping: 'col1=now()''

In this example, you must create col1 in a CQL table with the following definition:

col1 timeuuid

You can use the now() function for mapping of multiple database columns:

topic:
  my_topic:
    my_ks:
      my_table:
        mapping: 'col1=now(), col2=now(), col3=now()''

In the example above, each occurrence of now() is evaluated and return a different TIMEUUID.

Behavior of now() with DELETE records

When the value of a record arrives to DataStax Apache Pulsar Connector instance, it could be a DELETE, assuming deletesEnabled is true; see deletesEnabled.

For example, consider a case where a user has mapping and used the now() function:

my_pk=value.my_pk, my_value=value.my_value, loaded_at=now()

If there is an insertion of a value that is null, such as:

"{\"my_pk\": 1234567, \"my_value\": null}";

In this scenario, the called now() function is ignored, and the record is deleted.

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