OleksiienkoMykyta commented on issue #1549: URL: https://github.com/apache/cassandra-gocql-driver/issues/1549#issuecomment-2687476887
Marking a collection as frozen serializes it into a single, immutable value, making it suitable for inclusion in primary keys, including partition keys. (https://cassandra.apache.org/doc/latest/cassandra/reference/cql-commands/create-table.html#column_definition) For example: ``` CREATE TABLE example_table ( user_id UUID, attributes FROZEN<map<text, text>>, event_id UUID, event_timestamp timestamp, PRIMARY KEY ((user_id, attributes), event_id) ); ``` > I would expect the same can happen when you use e.g. cqlsh. I tried looking up Cassandra docs whether using frozen map in a partition key is supported, but couldn't find anything. In theory, there are possible such issues, however, I didn't succeed in reproducing it with the given details. I would like to close it as stale, but we always can re-open it if someone mentions a similar issue. @joao-r-reis, maybe we should provide users with such a method that sorts keys, or update existing marshaling logic(I don't think that it will cause any issues), or it's better to leave it to user-side? > If you want to use a map in a partition key, the safest seems to be to serialize it manually (you can implement `gocql.Marshaler` so that you always use a canonical representation (i.e. sort keys). I would even use `blob` or `text` type instead of frozen map in the database so that you always know that you need to serialize the labels manually in sorted order. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
