• Glossary
  • Support
  • Downloads
  • DataStax Home
Get Live Help
Expand All
Collapse All

DataStax Pulsar Connector

    • Getting Started
      • About the DataStax Apache Pulsar™ Connector
        • System requirements
      • Pulsar Connector release notes
      • Installing DataStax Apache Pulsar™ Connector
      • Pulsar Connector single instance quick start
    • Guides and examples
      • Configuration
        • Configuring parallelism
        • Specify writetime timestamp column
        • Setting row-level TTL values from Pulsar fields
        • Pass Pulsar Connector settings directly to the DataStax Java driver
        • Mapping pulsar topics to database tables
          • Determining topic data structure
          • Mapping basic messages to table columns
          • Mapping a message that contain JSON fields
            • Mapping a message that contains both basic and JSON fields
            • Mapping JSON messages
          • Mapping Avro messages
          • Extract Pulsar record header values
          • Mapping messages to table that has a User Defined Type
          • Mapping a topic to multiple tables
          • Multiple topics to multiple tables
          • Provide CQL queries in mappings
          • The now() function in mappings
      • Operations
        • About operating and maintaining the DataStax Connector
        • Scaling the DataStax Apache Pulsar™ Connector
        • Changing the topic or table schema
        • Restarting the DataStax Apache Pulsar™ Connector
        • Displaying the DataStax Apache Pulsar™ Connector configuration
        • Updating the DataStax Apache Pulsar™ Connector configuration
        • Deleting the DataStax Apache Pulsar™ Connector
        • Getting the DataStax Connector status
      • Security
        • Using internal or LDAP authentication
      • DataStax Apache Pulsar™ Connector metrics
      • Troubleshooting
        • Record fails to write
        • Writing fails because of mutation size
        • Data parsing fails
        • Loading balancing datacenter is not specified
    • Reference
      • DataStax Apache Pulsar™ Connector details
      • DataStax connection
      • Pulsar topic-to-table settings
      • Converting date and times for a topic
      • Using the DataStax Apache Pulsar™ Connector with DataStax Enterprise authentication
        • Internal or LDAP authentication
      • SSL encrypted connection
      • Configure error handling
  • DataStax Pulsar Connector
  • Guides and examples
  • Configuration
  • Mapping pulsar topics to database tables
  • Mapping Avro messages

Mapping Avro messages

The DataStax Apache Pulsar™ Connector supports mapping individual fields from Avro formatted key or values.

In this example, the key is a basic string and the value is Avro format. The Pulsar topic name is users_topic and have the following records:

key value

user0

{“name”: “chris”, “favorite_number”:14, “favorite_color”: “blue”}

user1

{“name”: “jack”, “favorite_number”:56, “favorite_color”: “pink”}

user2

{“name”: “shereen”, + “favorite_number”:7, + “favorite_color”: “black”}

user3

{“name”: “kimberly”, “favorite_number”:11, “favorite_color”: “orange”}

user4

{“name”: “taryn”, + “favorite_number”:37, + “favorite_color”: “green”}

The value field uses the following Avro Schema: { "namespace": "example.avro", "type": "record", "name": "user", "fields": [ {"name": "name", "type": "string"}, {"name": "favorite_number", "type": “int”}, {"name": "favorite_color", "type": “string”} ]

The DataStax keyspace name is users_keyspace and table is users_table.

userid name favoritenumber favoritecolor

user0

chris

14

blue

user1

jack

56

pink

user2

shereen

7

black

user3

kimberly

11

orange

user4

taryn

37

green

To create the table use the following command:

CREATE TABLE users_keyspace.users_table (userid text primary key, name text,
          favoritenumber int, favoritecolor text);

Configure the connector and use the following map specification:

topic:
    users_topic:
        users_keyspace:
            users_table:
                mapping: 'userid=key, name=value.name, favoritenumber=value.favorite_number, favoritecolor=value.favorite_color'
Mapping JSON messages Extract Pulsar record header values

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

© DataStax | Privacy policy | Terms of use

DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.

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.

landing_page landingpage