[ https://issues.apache.org/jira/browse/CASSANDRA-7396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14127503#comment-14127503 ]
Robert Stupp edited comment on CASSANDRA-7396 at 9/9/14 8:36 PM: ----------------------------------------------------------------- Proposal ("map" used for map columns, "set" for set columns, "list" for list columns) : * {{map\[key]}} to return single map value or {{null}} * {{map?\[key]}} tests whether single map key exists ({{true}} or {{false}}) * {{map\[key1..key2]}} to return sliced map * {{map?\[key1..key2]}} to return set with keys that are present in the map * {{map\[..key2]}} to return sliced map * {{map?\[..key2]}} to return set with keys that are present in the map * {{map\[key1..]}} to return sliced map * {{map?\[key1..]}} to return set with keys that are present in the map * {{set\[key]}} returns {{true}} or {{false}} whether a single element exists * {{set\[key1..key2]}} to return sliced set (check values of multiple elements) * {{set\[key1..]}} to return sliced set (check values of multiple elements) * {{set\[..key2]}} to return sliced set (check values of multiple elements) * {{list\[idx]}} to return single list element * {{list?\[idx]}} tests whether single list element exists ({{true}} or {{false}}) * {{list\[idx1..idx2]}} to return sliced list - list has length {{idx2-idx1+1}} * {{list?\[idx1..idx2]}} to return sliced list with {{true}} or {{false}} indicating whether an element exists (is no tnull) * {{sizeof(map)}}, {{sizeof(set)}}, {{sizeof(list)}} to return size of map/set/list Restriction for {{key1..key2}} : {{key1}} must be less than {{key2}} Using these collection operations on parts of primary key columns would require special handling. Primary key columns are stored in their serialized byte representation - so it would need deserialzation, handling, 2nd serialization. All would be added to {{unaliasedSelector}} in {{Cql.g}}. Other thoughts? I've built a POC for slicing (except {{sizeof}} functions) availabile at github at https://github.com/snazy/cassandra/tree/7396-coll-slice to illustrate functionality. That POC does not use column slicing to read only the requested values. In fact I do not know how to read only a map key „foobar“ from a table with clustering keys. AFAIK will the "internal column name“ something like "clusteringKey:mapColumnName:mapColumnKey“. Such a read optimization could be done for tables that not not have a clustering key. But there’s room for optimization to prevent unnecessary internal serialization-deserialization-serialization sequences for the above collection operations by using only those {{Cell}} s that will be returned (stuff around {{SelectStatement.addValue}}). was (Author: snazy): Proposal for {{SELECT}} ("map" used for map columns, "set" for set columns, "list" for list columns): * {{map\[key]}} to return single map value or {{null}} * {{map?\[key]}} tests whether single map key exists ({{true}} or {{false}}) * {{map\[key1..key2]}} to return sliced map * {{map?\[key1..key2]}} to return set with keys that are present in the map * {{map\[..key2]}} to return sliced map * {{map?\[..key2]}} to return set with keys that are present in the map * {{map\[key1..]}} to return sliced map * {{map?\[key1..]}} to return set with keys that are present in the map * {{set\[key]}} returns {{true}} or {{false}} whether a single element exists * {{set\[key1..key2]}} to return sliced set (check values of multiple elements) * {{set\[key1..]}} to return sliced set (check values of multiple elements) * {{set\[..key2]}} to return sliced set (check values of multiple elements) * {{list\[idx]}} to return single list element * {{list?\[idx]}} tests whether single list element exists ({{true}} or {{false}}) * {{list\[idx1..idx2]}} to return sliced list - list has length {{idx2-idx1+1}} * {{list?\[idx1..idx2]}} to return sliced list with {{true}} or {{false}} indicating whether an element exists (is no tnull) * {{sizeof(map)}}, {{sizeof(set)}}, {{sizeof(list)}} to return size of map/set/list Restriction for {{key1..key2}} : {{key1}} must be less than {{key2}} Using these collection operations on parts of primary key columns would require special handling. Primary key columns are stored in their serialized byte representation - so it would need deserialzation, handling, 2nd serialization. All would be added to {{unaliasedSelector}} in {{Cql.g}}. Other thoughts? I've built a POC for slicing (except {{sizeof}} functions) availabile at github at https://github.com/snazy/cassandra/tree/7396-coll-slice to illustrate functionality. That POC does not use column slicing to read only the requested values. In fact I do not know how to read only a map key „foobar“ from a table with clustering keys. AFAIK will the "internal column name“ something like "clusteringKey:mapColumnName:mapColumnKey“. Such a read optimization could be done for tables that not not have a clustering key. But there’s room for optimization to prevent unnecessary internal serialization-deserialization-serialization sequences for the above collection operations by using only those {{Cell}}s that will be returned (stuff around {{SelectStatement#addValue}}). > Allow selecting Map key, List index > ----------------------------------- > > Key: CASSANDRA-7396 > URL: https://issues.apache.org/jira/browse/CASSANDRA-7396 > Project: Cassandra > Issue Type: New Feature > Components: API > Reporter: Jonathan Ellis > Labels: cql > Fix For: 3.0 > > > Allow "SELECT map['key]" and "SELECT list[index]." (Selecting a UDT subfield > is already supported.) -- This message was sent by Atlassian JIRA (v6.3.4#6332)