Working with partitioners in Amazon Keyspaces - Amazon Keyspaces (for Apache Cassandra)

Working with partitioners in Amazon Keyspaces

In Apache Cassandra, partitioners control which nodes data is stored on in the cluster. Partitioners create a numeric token using a hashed value of the partition key. Cassandra uses this token to distribute data across nodes. Clients can also use these tokens in SELECT operations and WHERE clauses to optimize read and write operations. For example, clients can efficiently perform parallel queries on large tables by specifying distinct token ranges to query in each parallel job.

With Amazon Keyspaces, you can choose to set the partitioner for your account to the Cassandra RandomPartitioner for compatibility with developer tools such as the Apache Spark Cassandra Connector. Amazon Keyspaces also provides a DefaultPartitioner, which returns the same TOKEN function results as the RandomPartitioner.

You can safely change your account-level partitioner at any time. You do not need to reload your Amazon Keyspaces data when you change the partitioner setting. Clients will automatically use the new partitioner setting the next time they connect.

You can change the partitioner by using the AWS Management Console or Cassandra Query Language (CQL).

AWS Management Console
  1. Sign in to the AWS Management Console, and open the Amazon Keyspaces console at

  2. In the navigation pane, choose Configuration.

  3. On the Configuration page, go to Edit partitioner.

  4. Select org.apache.cassandra.dht.RandomPartitioner.


    You have to disconnect and reconnect to Amazon Keyspaces for requests to use the new partitioner.

Cassandra Query Language (CQL)
  1. To see which partitioner is configured for the account, you can use the following query.

    SELECT partitioner from system.local;

    If the partitioner hasn't been changed, the query has the following output.

    partitioner -------------------------------------------- com.amazonaws.cassandra.DefaultPartitioner
  2. To update the partitioner to the RandomPartitioner, you can use the following query.

    UPDATE system.local set partitioner='org.apache.cassandra.dht.RandomPartitioner' where key='local';
  3. To confirm that the partitioner has been set, you can run the SELECT query again. Note that due to eventual read consistency, the response might not reflect the results of the recently completed partitioner change yet. If you repeat the SELECT operation again after a short time, the response should return the latest data.

    SELECT partitioner from system.local;

    You have to disconnect and reconnect to Amazon Keyspaces so that requests use the new partitioner.