I know the title is a bit broad, but I have tried a bunch of things with different errors, so I was going to use this space to describe each of them. I have a model in datastax's python-driver below:
class DIDSummary(Model):
__keyspace__ = 'processor_api'
did = columns.Text(required=True, primary_key=True, partition_key=True)
month = columns.DateTime(required=True, primary_key=True, partition_key=True)
direction = columns.Text(required=True)
duration = columns.Counter(required=True)
cost = columns.Counter(required=True)
but then when I try this:
didsummaries = DIDSummary.filter(did__in=dids, month__in=datetime_range)
I get this error:
code=2200 [Invalid query] message="Partition KEY part did cannot be restricted by IN relation (only the last part of the partition key can)"
I then tried this:
class DIDSummary(Model):
# ...
month = columns.DateTime(required=True, primary_key=True)
# ...
Which brought up the error:
code=2200 [Invalid query] message="Clustering column "month" cannot be restricted by an IN relation"
I also tried this:
class DIDSummary(Model):
# ...
month = columns.DateTime(required=True, primary_key=True, index=True)
# ...
Which gave me this error:
InvalidRequest: code=2200 [Invalid query] message="Secondary indexes are not supported on counter tables"
When I tried to sync_table(DIDSummary)
Finally, I tried to do this:
class DIDSummary(Model):
# ...
month = columns.DateTime(required=True, primary_key=True)
direction = columns.Text(required=True)
# ...
Which wouldn't even let me run the server, ending up with this error in the log:
cassandra.cqlengine.models.ModelDefinitionException: counter models may not have data columns
Any help on how I should better design this so I can run the above command would be greatly appreciated. Thanks!
EDIT: I also have to do this:
didsummaries = DIDSummary.filter(did__in=dids, month=month)
which means that actually did
has to be the last part of my partition_key. Can I just assign a random uuid to each element and just lookup the elements based on primary_keys and indexes? Would that work? I'm super lost.