Returning data from collection columns

Collections do not differ from other columns in retrieval. To query for a subset of the collection, a secondary index for the collection must be created.

  • Retrieve teams for a particular cyclist id from the set.

     SELECT lastname, teams FROM cycling.cyclist_career_teams WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;

    To query a table containing a collection, the database retrieves the collection in its entirety. Keep collections small enough to be manageable because the collection store in memory. Alternatively, construct a data model to replace a collection if it must accommodate large amounts of data.

    The database returns results in an order based on elements types in the collection. For example, a set of text elements is returned in alphabetical order. If you want elements of the collection returned in insertion order, use a list.

  • Retrieve events stored in a list from the upcoming calendar for a particular year and month.

     SELECT * FROM cycling.upcoming_calendar WHERE year=2015 AND month=06;

    The order is not alphabetical, but rather in the order of insertion.

  • Retrieve teams for a particular cyclist id from the map.

     SELECT lastname, firstname, teams FROM cycling.cyclist_teams WHERE id=5b6962dd-3f90-4c93-8f61-eabfa4a803e2;

    The order of the map output depends on the key type of the map. In this case, the key is an integer type.


Was this helpful?

Give Feedback

How can we improve the documentation?

© 2024 DataStax | Privacy policy | Terms of use

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: +1 (650) 389-6000,