jackr
jackr

Reputation: 1437

What's CQL 'PRIMARY KEY ((k1), k2, k3)' mean?

In CQL code I'm maintaining (author not available), I find a Cassandra table declaration that says, in part

PRIMARY KEY ((k1), k2, k3)

Do those inner parens mean anything in this case? Or is it merely redundant?

To clarify:

  1. I know what PRIMARY KEY (k1, k2, k3) would mean (partition on k1, cluster on k2 and k3).
  2. I know what PRIMARY KEY ((k1, k2), k3) would mean (partition on (k1, k2), cluster on k3)
  3. But is the cited code just equivalent to #1?

Upvotes: 1

Views: 151

Answers (1)

Aaron
Aaron

Reputation: 57758

Yes, PRIMARY KEY ((k1), k2, k3) is basically the same as PRIMARY KEY (k1, k2, k3). In the case of designating a single partition key, you can opt to not specify the partition parens. They are really only necessary if you are creating a composite partition key (like you are with your point #2).

Upvotes: 3

Related Questions