• Glossary
  • Support
  • Downloads
  • DataStax Home
Get Live Help
Expand All
Collapse All

CQL for DSE

  • Overview
    • Cassandra structure
    • About CQL
    • CQL quick reference
    • Known issues
  • Getting started
    • Vector Search Quickstart
    • CQL Quickstart
    • SAI Quickstart
    • DSE Search Indexing Quick Start
  • Planning
    • Data modeling
      • Data modeling concepts
      • Data modeling analysis
  • Connecting
    • cqlsh (startup options)
      • Accessing data using CQL
        • Starting the standalone cqlsh tool
        • Starting cqlsh
    • Developing
      • Introduction to CQL
      • Managing keyspaces
        • Keyspace concepts
        • Create a keyspace
        • Check a keyspace
        • Alter a keyspace
        • Drop a keyspace
      • Managing tables
        • Table concepts
        • Data types
        • Create a table
        • Check a table
        • Alter a table
        • Truncate a table
        • Drop a table
      • Managing columns
        • Managing columns
        • Create a table column
        • Check column existence
        • Alter a table column
        • Drop a column
        • User-defined type (UDT) overview
          • Create a user-defined type (UDT)
          • Check for user-defined type (UDT) existence
          • Alter a user-defined type (UDT)
          • Drop a user-defined type (UDT)
        • User-defined functions (UDFs) and user-defined aggregates (UDAs) overview
          • Create a user-defined function (UDF)
          • Check a user-defined function (UDF)
          • Drop a user-defined function (UDF)
          • Create a user-defined aggregate function (UDA)
          • Checking a user-defined aggregate (UDA)
          • Drop a user-defined aggregate (UDA)
      • Managing Materialized views
        • Materialized views concepts
        • Known limitations of materialized views
        • Create a materialized view (MV)
        • Alter a materialized view (MV)
        • Drop a materialized view
        • Frequently asked questions about materialized views
      • Indexing Tables
        • Indexing concepts
        • Storage-Attached Indexing (SAI) Overview
          • SAI concepts
          • SAI Quickstart
          • SAI FAQ
          • Create SAI index
          • Alter SAI index
          • Drop SAI index
          • Querying with SAI
          • Configure SAI indexes
          • Monitor SAI indexes
          • SAI write path and read path
        • Secondary indexes (2i) overview
          • Secondary index (2i) concepts
          • When to use an index
          • Building and maintaining secondary indexes (2i)
          • Create a secondary index (2i)
            • Create a 2i on a collection column
          • Check secondary index (2i) existence
          • Alter a secondary index (2i)
          • Drop a secondary index (2i)
        • Search indexes overview
          • Search index commands
          • Adjusting timeout for index management
          • Creating a search index
          • Configuring search index joins
          • Joining cores
          • Reloading the search index
          • Removing a search index
          • Managing search index fields
            • Syntax for changing schema settings
            • Search index schema field types
            • Adding a new field type
            • Adding a column to the index
            • Indexing tuples and UDTs fields
              • Tuple configuration example
              • UDT configuration example
              • Nesting tuples and UDTs
              • Tuples and UDTs as CQL map values
            • Indexing map columns
            • Indexing a column for different analysis
            • Dropping columns from the index
          • Updating the index after data expires (TTL)
          • Inserting, updating, and deleting data
          • Search indexing examples
        • Search index examples
          • Search index examples
            • Creating a demo keyspace for tutorials
            • Indexing and querying polygons
      • Inserting and updating data
        • Insert simple data
        • Set column
        • List fields
        • Map fields
        • Tuple
        • User-defined type (UDT) column
        • Insert static data
        • UUID and timeuuid column
        • Date column
        • Time column
        • Timestamp column
        • Duration column
        • Update counter
        • Lightweight transactions (LWTs)
        • Inserting JSON formatted values
        • Batching inserts and updates
          • Batching inserts, updates, and deletes
          • Good use of BATCH statement
          • Misuse of BATCH statement
        • Importing data from a CSV file
        • Setting the time-to-live (TTL) for value
          • Inserting, updating, and deleting data
      • Deleting data
        • Deleting values from a column or entire row
        • Expiring data with time-to-live
        • Expiring data with TTL example
      • Querying and retrieving data
        • Using a SELECT statement
        • Restricting queries using WHERE clauses
          • Partition keys
          • Clustering columns
          • Retrieval using the IN keyword
          • Sorting and limiting results
        • Returning data from collection columns
        • Aggregating results
        • Using user-defined functions (UDF)
        • Applying user-defined aggregate (UDA) functions
          • Testing performance impact using tracing
        • Formatting query results as JSON
        • Retrieving the write timestamp
        • Using tracing
          • Tracing performance
        • DSE Search index querying
        • Search index filtering best practices
          • Search index syntax
          • search-index:si-query-syntax.adoc#siIndexedColumns
          • search-index:si-query-syntax.adoc#basicSolrSyntax
          • search-index:si-query-syntax.adoc#queriesJSON
          • search-index:si-query-syntax.adoc#siEscapeCharacters
        • Native CQL search queries
        • Identifying the partition key
        • Filtering on terms
          • Filtering on words, phrases, or substrings
          • Fuzzy search
        • UDT query examples
        • Querying a CQL collection set
        • Using date ranges in solr_query
        • Geospatial queries for Point and LineString
        • Spatial queries with polygons require JTS
        • Using dynamic fields
        • Limiting results and paging
        • Restricted query routing
    • Securing overview
      • Security quickstart
      • Using cqlsh with authentication
      • System tables for authentication and authorization
  • Cycling Examples
    • Setting up the cycling keyspace
    • User-defined types (UDTs)
      • basic_info
      • basic_info_withTTL
      • fullname
      • race
    • User-defined functions (UDFs) and user-defined aggregates (UDAs)
      • flog
      • left
      • average_state
      • average_final
      • Cycling user-defined aggregate team_average
    • Tables
      • birthday_list
      • calendar
      • comments
      • country_flag
      • cyclist_alt_stats
      • cyclist_base
      • cyclist_career_teams
      • cyclist_category
      • cyclist_emails
      • cyclist_expenses
      • cyclist_id
      • cyclist_name
      • cyclist_points
      • cyclist_races
      • cyclist_sponsors
      • cyclist_stats
      • cyclist_teams
      • events
      • popular_count
      • race_sponsors
      • race_starts
      • race_times
      • race_winners
      • rank_by_year_and_name
      • team_average
      • upcoming_calendar
    • Materialized views (MVs)
      • cyclist_by_age-mv
    • Search indexes
      • Search index examples
      • comments search index
    • SASI indexes
      • Index on cyclist_name
    • Access control
      • Cycling internal
    • Cycling queries
      • Aggregating cycling data
    • Reference
      • CQL quick reference
      • Understanding the CQL command syntax
      • Data types
        • Creating a blob column
        • Date, time, and timestamp format
        • Solr field type reference for DSE Search
      • Operators
      • CQL native functions
      • CQL native aggregates
      • System and virtual tables
        • System tables
          • Keyspace tables
          • Querying system tables
          • Functions, aggregates, and user types
        • Virtual tables
          • Virtual keyspaces and tables
          • Virtual tables for SAI indexes and SSTables
      • cqlsh (startup options)
        • Configuring a cqlshrc file
        • Starting cqlsh on a search node
      • CQL shell (cqlsh) reference
        • CAPTURE
        • CLEAR
        • CONSISTENCY
        • COPY TO
        • COPY FROM
        • DESCRIBE AGGREGATE
        • DESCRIBE CLUSTER
        • DESCRIBE SCHEMA
        • DESCRIBE FUNCTION
        • DESCRIBE INDEX
        • DESCRIBE KEYSPACE
        • DESCRIBE MATERIALIZED VIEW
        • DESCRIBE SEARCH INDEX
        • DESCRIBE TABLE
        • DESCRIBE TYPE
        • EXECUTE AS
        • EXPAND
        • EXIT
        • LOGIN
        • PAGING
        • SERIAL CONSISTENCY
        • SHOW
        • SOURCE
        • TIMING
        • TRACING
      • CQL commands
        • ALTER KEYSPACE
        • ALTER MATERIALIZED VIEW
        • ALTER ROLE
        • ALTER SEARCH INDEX CONFIG
        • ALTER SEARCH INDEX SCHEMA
        • ALTER TABLE
        • ALTER TYPE
        • ALTER USER (Deprecated)
        • BATCH
        • COMMIT SEARCH INDEX
        • CREATE AGGREGATE
        • CREATE CUSTOM INDEX
        • CREATE FUNCTION
        • CREATE INDEX
        • CREATE KEYSPACE
        • CREATE MATERIALIZED VIEW
        • CREATE ROLE
        • CREATE SEARCH INDEX
        • CREATE TABLE
        • CREATE TYPE
        • CREATE USER (Deprecated)
        • DELETE
        • DROP AGGREGATE
        • DROP FUNCTION
        • DROP INDEX
        • DROP KEYSPACE
        • DROP MATERIALIZED VIEW
        • DROP ROLE
        • DROP SEARCH INDEX
        • DROP TABLE
        • DROP TYPE
        • DROP USER (Deprecated)
        • GRANT
        • INSERT
        • LIST PERMISSIONS
        • LIST ROLES
        • LIST USERS (Deprecated)
        • REBUILD SEARCH INDEX
        • RELOAD SEARCH INDEX
        • RESTRICT
        • RESTRICT ROWS
        • REVOKE
        • SELECT
        • TRUNCATE
        • UNRESTRICT
        • UNRESTRICT ROWS
        • UPDATE
        • USE
  • CQL for DSE
  • Cycling Examples
  • Tables
  • events
Edit this Page

events

Uses month and date of cycling races to show how to get ranges that span clustering columns. Example of copying data from a CSV into the table.

events table

SOURCE 'keyspace-create-simple.cql';
SOURCE 'keyspace-use.cql';

DROP TABLE IF EXISTS cycling.events;

// tag::table-create-events[]
CREATE TABLE IF NOT EXISTS cycling.events (
  year int,
  start_month int,
  start_day int,
  end_month int,
  end_day int,
  race text,
  discipline text,
  location text,
  uci_code text,
  PRIMARY KEY (
    (year, discipline), start_month, start_day, race
  )
);
// end::table-create-events[]

COPY cycling.events
FROM 'events-data.csv'
WITH HEADER = true
  AND DELIMITER = '|';

// tag::select_with_in_and_equals_allow_filtering[]
SELECT *
FROM cycling.events
WHERE race = 'Superprestige - Hoogstraten -2017'
  AND start_month IN (1, 2)
ALLOW FILTERING;
// end::select_with_in_and_equals_allow_filtering[]

// tag::select_count[]
SELECT start_month, MAX(start_day), COUNT(*)
FROM cycling.events
WHERE year = 2017
  AND discipline = 'Cyclo-cross';
// end::select_count[]

CAPTURE 'select_all_from_events_with_order_by.results';
// tag::select_with_order_by[]
SELECT *
FROM cycling.events
WHERE year = 2017
  AND discipline = 'Cyclo-cross'
  AND start_month = 1
  AND start_day = 1
ORDER BY race;
// end::select_with_order_by[]
CAPTURE OFF;

// tag::select_with_order_multiple_columns[]
SELECT *
FROM cycling.events
WHERE year = 2017
  AND discipline = 'Cyclo-cross'
  AND start_month = 1
ORDER BY start_day, race;
// end::select_with_order_multiple_columns[]

// tag::select_with_where[]
SELECT *
FROM cycling.events
WHERE year = 2017
  AND discipline = 'Cyclo-cross'
  AND start_month = 1
  AND start_day = 1;
// end::select_with_where[]

CAPTURE 'select_from_events_non_existing_year.results';
// tag::select_with_non_existing_year[]
SELECT start_month, MAX(start_day)
FROM cycling.events
WHERE year = 2022
ALLOW FILTERING;
// end::select_with_non_existing_year[]
CAPTURE OFF;

Data from CSV

Insert the following comma separated data:

Year|Discipline|Start_Month|Start_Day|Race|End_Month|End_Day|Location|UCI_code
2017|Cyclo-cross|1|1|DVV verzekeringen trofee - GP Sven Nys|||Baal|C1 
2017|Road|1|1|Mitchelton Bay Cycling Classic|1|3|Geelong Victoria|CRT 
2017|Road|1|4|Cycling Australia Road National Championships|1|8| Ballarat| CN 
2017|Cyclo-cross|1|8|Belgian Cyclo-cross National Championships|||Oostende|CN 
2017|Cyclo-cross|1|8|British Cyclo-cross National Championships|||Bradford|CN 
2017|Cyclo-cross|1|8|Dutch Cyclo-cross National Championships|||Holland|CN 
2017|Cyclo-cross|1|8|USA Cycling Cyclo-Cross National Championships|||Hartford CT|CN 
2017|Road|1|14|Santos Womens Tour|1|17|South Australia|WE 
2017|Road|1|15|Tour Down Under|1|22|South Australia|WT 
2017|Cyclo-cross|1|15|UCI Cyclo-cross World Cup Fiuggi Regione Lazio|||Fiuggi|CDM 
2017|Cyclo-cross|1|22|UCI Cyclo-cross World Cup Hoogerheide|||Hoogerheide|CDM 
2017|Road|1|23|Vuelta Ciclista a la Provincia de San Juan|1|29|San Juan| 
2017|Road|1|26|Cadel Evans Great Ocean Road Race - Towards Zero Race Melbourne|||Melbourne|CRT 
2017|Road|1|26|Challenge Mallorca: Trofeo Porreres-Felanitx-Ses Salines-Campos|||Mallorca| 
2017|Road|1|28|Challenge Mallorca: Trofeo Serra de Tramuntana -2017|||Mallorca| 
2017|Road|1|28|Cadel Evans Great Ocean Road Race|||Geelong| WE 
2017|Road|1|28|Challenge Mallorca: Trofeo Andratx-Mirador des Colomer|||Mallorca| 
2017|Cyclo-cross|1|28|UCI Cyclo-cross World Championships|1|29|Bieles|CM 
2017|Road|1|29|Cadel Evans Great Ocean Road Race|||Geelong|WT 
2017|Road|1|29|Grand Prix Cycliste la Marseillaise|||France| 
2017|Road|1|29|Mallorca Challenge: Trofeo Palma|||Mallorca| 
2017|Road|1|29|Dubai Tour|2|4|Dubai| 2.1 HC
2017|Road|1|31|Ladies Tour of Qatar|2|3|Qatar|WE 
2017|Road|2|1|Jayco Herald Sun Tour|2|5|Victoria| 
2017|Road|2|1|Volta a la Comunitat Valenciana|2|5|Valencia| 
2017|Road|2|1|Etoile de Besseges|2|5|Languedoc-Roussillon| 
2017|Cyclo-cross|2|4|DVV verzekeringen trofee - Krawatencross|||Lille|C1 
2017|Cyclo-cross|2|4|DVV verzekeringen trofee - Krawatencross|||Lille|C1 
2017|Road|2|5|G.P. Costa degli Etruschi|||Italy| 
2017|Cyclo-cross|2|4|Superprestige - Hoogstraten -2017|||Belgium|C1 
2017|Road|2|6|Tour of Qatar|2|10|Qatar|WT 
2017|Road|2|9|South African Road Championships|2|12|Western Cape|CN 
2017|Cyclo-cross|2|11|Superprestige - Middelkerke -2017|||Middelkerke|C1 
2017|Road|2|11|Vuelta Ciclista a la Region de Murcia|||Murcia |1.1 
2017|Road|2|12|Clasica de Almeria|||Almeria|1.1 
2017|Road|2|11|Trofeo Laigueglia|||Liguria|HC 
2017|Road|2|14|Tour of Oman|2|19|Oman|  HC 
2017|Road|2|15|Volta ao Algarve em Bicicleta|2|19|Algarve|HC 
2017|Road|2|15|Vuelta a Andalucia Ruta Ciclista Del Sol|2|19|Andalucia|HC
2017|Track|2|17|UCI Track World Cup III|2|19|  Cali|CDM 
2017|Road|2|18|Tour Cycliste International du Haut Var-matin|2|19|Provence  |2.1 
2017|Road|2|21|Tour Cycliste International La Provence|2|13|Provence|2.1 
2017|Road|2|22|Le Tour de Langkawi|3|1|Langkawi|HC 
2017|Road|2|23|Abu Dhabi Tour|2|26|Abu Dhabi|WT 
2017|Road|2|25|Faun Environnement - Classic de lArdeche Rhone Crussol|||Ardeche   | 1.1 
2017|Road|2|25|Omloop Het Nieuwsblad Elite|||Belgium|WT 
2017|Road|2|25|Omloop Het Nieuwsblad Elite Women|||Gent|WWT 
2017|Track|2|25|UCI Track World Cup IV    Track|2|26|Los Angeles|CDM 
2017|Road|2|26|Kuurne-Brussel-Kuurne|||Kuurne|HC 
2017|Road|2|26|Omloop van het Hageland - Tielt-Winge|||Belgium|WE 
2017|Road|3|1|Le Samyn|||Hainaut|1.1 
2017|Road|3|1|Le Samyn des Dames|||Hainaut|WE 
2017|Road|3|4|Strade Bianche|||Tuscany|WT 
2017|Road|3|4|Strade Bianche Women|||Tuscany|WWT 
2017|Road|3|5|Dwars door West-Vlaanderen Johan Museeuw Classic|||Flanders| 1.1 
2017|Road|3|5|GP Industria and Artigianato|||Larciano|HC 
2017|Road|3|5|Paris - Nice|3|12|France|WT 
2017|Road|3|8|Semana Ciclista Valenciana|3|11|Valencia|WE 
2017|Road|3|8|Tirreno-Adriatico|3|14|Italy|WT 
2017|Road|3|8|Oceania Championships|3|14|Canberra|CC 
2017|Road|3|11|Ronde van Drenthe|||Netherlands|WWT 
2017|Road|3|12|Drentse Acht van Westerveld|||Dwingeloo|WE 
2017|Road|3|15|Nokere Koerse - Danilith Classic|||Flanders|HC 
2017|Road|3|17|Handzame Classic|||Flanders|1.1 
2017|Road|3|18|Classic Loire Atlantique|||Loire|1.1 
2017|Road|3|18|Milan-San Remo|||Italy|WT 
2017|Road|3|18|Tucson Bicycle Classic|||Tucson Arizona|NE 
2017|Mountain Bike|3|19|Cape Epic|3|26|Cape Town|SHC 
2017|Road|3|19|Trofeo Alfredo Binda Comune di Cittiglio|||Italy|WWT 
2017|Road|3|20|Volta Ciclista a Catalunya|3|26|Catalunya|WT 
2017|Road|3|22|Dwars Door Vlaanderen|||Flanders|WT 
2017|Road|3|22|Dwars door Vlaanderen women|||Waregem|WE 
2017|Road|3|23|Settimana Internazionale Coppi e Bartali|3|26|Emilia-Romagna|2.1 
2017|Road|3|24|E3 Harelbeke|||Flanders|WT 
2017|Road|3|26|Gent Wevelgem|||Flanders|WT 
2017|Road|3|26|Gent Wevelgem Women|||Belgium|WWT 
2017|Road|3|28|Driedaagse De Panne-Koksijde|3|30|West Flanders|HC 
2017|Road|3|29|Pajot Hills Classic|||Flemish Brabant|WE  
cyclist_teams popular_count

General Inquiries: +1 (650) 389-6000 info@datastax.com

© DataStax | Privacy policy | Terms of use

DataStax, Titan, and TitanDB are registered trademarks of DataStax, Inc. and its subsidiaries in the United States and/or other countries.

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.

landing_page landingpage