Unable to read static column with clustering key constraint

Description

Hello.

We are using Cassandra for time series modeling. Values in a table are inserted with lightweight transactions (CAS).

In the table we have a partition key, a clustering key, and a static column, value from which has to be extracted on read.

We are using select queries of two types: with partition and clustering keys constraints and with partition key constraint only.

When select query without clustering key constraint is applied to an empty partition, the query will return exactly one object with a value from the static column mapped to the corresponding field of that object.

When query with clustering key constraint is applied, and there's exist at least one row in the table that is satisfied this constraint, the query will return all such rows mapped to the objects. The value from the static column will be stored in the appropriate fields of all these objects.

But, if query with clustering key constraint is applied to the empty partition, this query will return an empty collection of objects, despite of what is stored in the static column in this partition. So, retrieval of the data from the static column in this case is not possible without performing an additional query with no clustering key constraint.

In the last case expected behavior would be to get an empty object with static data mapped to it, similarly to the first case (when query without clustering key constraint is applied to the empty partition).

We are thinking, this behavior of the driver is an issue, because additional query, potentially, may lead to the race condition and the overhead due to paxos and lightweight transactions mechanism when reads are performed on a serial consistency level.

This behavior is present in C# driver versions 3.2.1 and 3.2.0.

Environment

None

Activity

Show:
Arthur Landim
May 15, 2017, 10:50 PM

Actually this is an behavior of cassandra, not the driver itself. Although the static column is attached to partition level, if your query do not have at least 1 row, it wont return the static columns when queried with clustering key.

Arthur Landim
May 15, 2017, 10:58 PM

As if its a behavior of cassandra, you can suggest this change at cassandra jira, https://issues.apache.org/jira/browse/CASSANDRA

Jorge Bay Gondra
May 16, 2017, 10:25 PM

Maybe you can make use of DISTINCT keyword?

For example

Not a Problem

Assignee

Unassigned

Reporter

Ivan Poroshin

Labels

Reproduced in

None

PM Priority

None

Fix versions

None

External issue ID

None

Doc Impact

None

Reviewer

None

Pull Request

None

Epic Link

None

Sprint

None

Pull Requests

None

Size

None

Components

Affects versions

Priority

Major