SAI docs for CEP-7
patch by Lorina Poland; reviewed by Mick Semb Wever for CASSANDRA-18231
|
|
@ -5,6 +5,11 @@ prerelease: true
|
|||
asciidoc:
|
||||
attributes:
|
||||
cass_url: 'http://cassandra.apache.org/'
|
||||
product: Cassandra
|
||||
cassandra: Apache Cassandra
|
||||
30_version: '3.0'
|
||||
22_version: '2.2'
|
||||
21_version: '2.1'
|
||||
nav:
|
||||
- modules/ROOT/nav.adoc
|
||||
- modules/cassandra/nav.adoc
|
||||
- modules/cassandra/nav.adoc
|
||||
|
|
@ -2,3 +2,15 @@
|
|||
** xref:master@_:ROOT:glossary.adoc[Glossary]
|
||||
** xref:master@_:ROOT:bugs.adoc[How to report bugs]
|
||||
** xref:master@_:ROOT:contactus.adoc[Contact us]
|
||||
** xref:master@_:ROOT:development/index.adoc[Development]
|
||||
*** xref:master@_:ROOT:development/gettingstarted.adoc[Getting started]
|
||||
*** xref:master@_:ROOT:development/ide.adoc[Building and IDE integration]
|
||||
*** xref:master@_:ROOT:development/testing.adoc[Testing]
|
||||
*** xref:master@_:ROOT:development/patches.adoc[Contributing code changes]
|
||||
*** xref:master@_:ROOT:development/code_style.adoc[Code style]
|
||||
*** xref:master@_:ROOT:development/how_to_review.adoc[Review checklist]
|
||||
*** xref:master@_:ROOT:development/how_to_commit.adoc[How to commit]
|
||||
*** xref:master@_:ROOT:development/documentation.adoc[Working on documentation]
|
||||
*** xref:master@_:ROOT:development/ci.adoc[Jenkins CI environment]
|
||||
*** xref:master@_:ROOT:development/dependencies.adoc[Dependency management]
|
||||
*** xref:master@_:ROOT:development/release_process.adoc[Release process]
|
||||
|
|
|
|||
|
After Width: | Height: | Size: 276 KiB |
|
After Width: | Height: | Size: 82 KiB |
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 184 KiB |
|
After Width: | Height: | Size: 154 KiB |
|
After Width: | Height: | Size: 78 KiB |
|
After Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 41 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
|
@ -0,0 +1,2 @@
|
|||
docker kill cassandra
|
||||
docker network rm cassandra
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
docker network create cassandra
|
||||
|
||||
docker run --rm -d --name cassandra --hostname cassandra --network cassandra cassandra
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
docker run --rm --network cassandra \
|
||||
-v "$(pwd)/data.cql:/scripts/data.cql" \
|
||||
-e CQLSH_HOST=cassandra -e CQLSH_PORT=9042 \
|
||||
-e CQLVERSION=3.4.6 nuvo/docker-cqlsh
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
docker run --rm -it --network \
|
||||
cassandra nuvo/docker-cqlsh cqlsh cassandra \
|
||||
9042 --cqlversion='3.4.5'
|
||||
|
|
@ -0,0 +1 @@
|
|||
DESCRIBE TABLE cycling.birthday_list;
|
||||
|
|
@ -0,0 +1 @@
|
|||
DROP INDEX IF EXISTS cycling.teams_idx;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
// This file contains CQL statements that generate errors.
|
||||
// This file can be run after the cycling keyspace is set up.
|
||||
|
||||
// InvalidRequest: Error from server: code=2200 [Invalid query]
|
||||
// message=“Altering of types is not allowed”
|
||||
ALTER TABLE cycling.cyclist_alt_stats ALTER favorite_color TYPE text;
|
||||
|
||||
// tag::select_all_from_cyclist_alt_stats_error[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_alt_stats
|
||||
WHERE birthday = '1982-01-29'
|
||||
AND nationality = 'Russia';
|
||||
// end::select_all_from_cyclist_alt_stats_error[]
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
// QUERY USING MULTIPLE INDEXES
|
||||
// DISCUSSION OF THE NEED FOR ALLOW FILTERING
|
||||
// Showing date upserts and queries
|
||||
// avg
|
||||
|
||||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::drop_cyclist_alt_stats[]
|
||||
DROP TABLE IF EXISTS cycling.cyclist_alt_stats;
|
||||
// end::drop_cyclist_alt_stats[]
|
||||
|
||||
// tag::cyclist_alt_stats[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.cyclist_alt_stats (
|
||||
id UUID PRIMARY KEY,
|
||||
lastname text,
|
||||
birthday date,
|
||||
nationality text,
|
||||
weight float,
|
||||
w_units text,
|
||||
height float,
|
||||
first_race date,
|
||||
last_race date
|
||||
);
|
||||
// end::cyclist_alt_stats[]
|
||||
|
||||
// tag::index_bday[]
|
||||
CREATE INDEX IF NOT EXISTS birthday_idx
|
||||
ON cycling.cyclist_alt_stats (birthday);
|
||||
// end::index_bday[]
|
||||
|
||||
// tag::index_nationality[]
|
||||
CREATE INDEX IF NOT EXISTS nationality_idx
|
||||
ON cycling.cyclist_alt_stats (nationality);
|
||||
// end::index_nationality[]
|
||||
|
||||
USE cycling;
|
||||
|
||||
// tag::insertnow[]
|
||||
INSERT INTO cycling.cyclist_alt_stats (
|
||||
id,
|
||||
last_race
|
||||
) VALUES (
|
||||
ed584e99-80f7-4b13-9a90-9dc5571e6821,
|
||||
todate(now())
|
||||
);
|
||||
// end::insertnow[]
|
||||
|
||||
// tag::insertdate[]
|
||||
INSERT INTO cycling.cyclist_alt_stats (
|
||||
id,
|
||||
first_race
|
||||
) VALUES (
|
||||
ed584e99-80f7-4b13-9a90-9dc5571e6821,
|
||||
'2006-03-15'
|
||||
);
|
||||
// end::insertdate[]
|
||||
|
||||
CAPTURE 'select_dates_from_cyclist_alt_stats.result';
|
||||
// tag::selectrace[]
|
||||
SELECT first_race, last_race, birthday
|
||||
FROM cycling.cyclist_alt_stats
|
||||
WHERE id = ed584e99-80f7-4b13-9a90-9dc5571e6821;
|
||||
// end::selectrace[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::updatestring[]
|
||||
UPDATE cycling.cyclist_alt_stats
|
||||
SET birthday = '1987-03-07'
|
||||
WHERE id = ed584e99-80f7-4b13-9a90-9dc5571e6821;
|
||||
// end::updatestring[]
|
||||
|
||||
// tag::updatenow[]
|
||||
UPDATE cycling.cyclist_alt_stats
|
||||
SET last_race = toDate(now())
|
||||
WHERE id = ed584e99-80f7-4b13-9a90-9dc5571e6821;
|
||||
// end::updatenow[]
|
||||
|
||||
// tag::insert[]
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (ed584e99-80f7-4b13-9a90-9dc5571e6821,'TSATEVICH', '1989-07-05', 'Russia', 64, 'kg', 1.69, '2006-03-15','2017-04-16');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (a9e96714-2dd0-41f9-8bd0-557196a44ecf,'ISAYCHEV', '1986-04-21', 'Russia', 80, 'kg', 1.88,'2003-04-22','2017-03-05');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (823ec386-2a46-45c9-be41-2425a4b7658e,'BELKOV', '1985-01-09', 'Russia', 71, 'kg', 1.84,'2002-03-22','2017-04-16');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (e0953617-07eb-4c82-8f91-3b2757981625,'BRUTT', '1982-01-29', 'Russia', 68, 'kg', 1.78,'1998-02-15','2017-04-16');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (078654a6-42fa-4142-ae43-cebdc67bd902,'LAGUTIN', '1981-01-14', 'Russia', 63, 'kg', 1.82,'1996-05-21','2010-10-02');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (d74d6e70-7484-4df5-8551-f5090c37f617,'GRMAY', '1991-08-25', 'Ethiopia', 63, 'kg', 1.75, '2006-05-21','2017-04-16');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (c09e9451-50da-483d-8108-e6bea2e827b3,'VEIKKANEN', '1981-03-29', 'Finland', 66, 'kg', 1.78,'1996-05-21','2012-10-02');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (f1deff54-7d96-4981-b14a-b70be4da82d2,'TLEUBAYEV', null, 'Kazakhstan', null, null, null, '2003-04-22','2017-04-16');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (1ba0417d-62da-4103-b710-de6fb227db6f,'PAULINHO', '1990-05-27', 'Portugal', null, null, null, '2006-03-15','2017-03-05');
|
||||
INSERT INTO cycling.cyclist_alt_stats (id, lastname, birthday, nationality, weight, w_units, height, first_race, last_race) VALUES (4ceb495c-55ab-4f71-83b9-81117252bb13,'DUVAL', '1990-05-27','France', null, null, null, '2006-03-15','2017-04-16');
|
||||
// end::insert[]
|
||||
|
||||
CAPTURE 'select_all_from_cyclist_alt_stats_filtering.result';
|
||||
// tag::select_success[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_alt_stats
|
||||
WHERE birthday = '1982-01-29'
|
||||
AND nationality = 'Russia'
|
||||
ALLOW FILTERING;
|
||||
// end::select_success[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::select_portugal[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_alt_stats
|
||||
WHERE birthday = '1990-05-27'
|
||||
AND nationality = 'Portugal'
|
||||
ALLOW FILTERING;
|
||||
// end::select_portugal[]
|
||||
|
||||
// tag::add[]
|
||||
ALTER TABLE cycling.cyclist_alt_stats
|
||||
ADD cyclist_age int;
|
||||
// end::add[]
|
||||
|
||||
CAPTURE 'select_id_age_from_cyclist_alt_stats.result';
|
||||
// tag::sadd[]
|
||||
SELECT id, cyclist_age AS age
|
||||
FROM cycling.cyclist_alt_stats
|
||||
LIMIT 3;
|
||||
// end::sadd[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::delete[]
|
||||
ALTER TABLE cycling.cyclist_alt_stats
|
||||
DROP cyclist_age;
|
||||
// end::delete[]
|
||||
|
||||
// tag::rename[]
|
||||
ALTER TABLE cycling.cyclist_alt_stats
|
||||
RENAME id TO cyclist_id;
|
||||
// end::rename[]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
CREATE KEYSPACE IF NOT EXISTS store WITH REPLICATION =
|
||||
{ 'class' : 'SimpleStrategy',
|
||||
'replication_factor' : '1'
|
||||
};
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
CREATE TABLE IF NOT EXISTS my_keyspace.my_table
|
||||
.
|
||||
.
|
||||
.
|
||||
WITH compaction = {
|
||||
'class' : 'LeveledCompactionStrategy',
|
||||
'sstable_size_in_mb' : '320' };
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
CREATE TABLE IF NOT EXISTS store.shopping_cart (
|
||||
userid text PRIMARY KEY,
|
||||
item_count int,
|
||||
last_update_timestamp timestamp
|
||||
);
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::cyclistSelectCountry[]
|
||||
SELECT * FROM cycling.cyclist_semi_pro WHERE country = 'GBR';
|
||||
// end::cyclistSelectCountry[]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
INSERT INTO store.shopping_cart
|
||||
(userid, item_count)
|
||||
VALUES ('4567', 20);
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
INSERT INTO store.shopping_cart
|
||||
(userid, item_count, last_update_timestamp)
|
||||
VALUES ('9876', 2, toTimeStamp(now()));
|
||||
INSERT INTO store.shopping_cart
|
||||
(userid, item_count, last_update_timestamp)
|
||||
VALUES ('1234', 5, toTimeStamp(now()));
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::drop[]
|
||||
DROP TABLE IF EXISTS cycling.birthday_list;
|
||||
// end::drop[]
|
||||
|
||||
DROP INDEX IF EXISTS cycling.blist_idx;
|
||||
DROP INDEX IF EXISTS cycling.blist_values_idx;
|
||||
|
||||
/* Map entries and regular index map fields example */
|
||||
|
||||
// tag::blisttable[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.birthday_list (
|
||||
cyclist_name text PRIMARY KEY,
|
||||
blist map<text, text>
|
||||
);
|
||||
// end::blisttable[]
|
||||
|
||||
// Create index on map ENTRIES
|
||||
// tag::entriesidx[]
|
||||
CREATE INDEX IF NOT EXISTS blist_idx
|
||||
ON cycling.birthday_list ( ENTRIES(blist) );
|
||||
// end::entriesidx[]
|
||||
|
||||
// Create index on map VALUES
|
||||
// tag::mapvaluesidx[]
|
||||
CREATE INDEX IF NOT EXISTS blist_values_idx
|
||||
ON cycling.birthday_list ( VALUES(blist) );
|
||||
// end::mapvaluesidx[]
|
||||
|
||||
// tag::insertentries[]
|
||||
INSERT INTO cycling.birthday_list (
|
||||
cyclist_name, blist
|
||||
) VALUES (
|
||||
'Allan DAVIS', { 'age':'35', 'bday':'27/07/1980', 'nation':'AUSTRALIA' }
|
||||
);
|
||||
|
||||
INSERT INTO cycling.birthday_list (
|
||||
cyclist_name, blist
|
||||
) VALUES (
|
||||
'Claudio VANDELLI', { 'age':'54', 'bday':'27/07/1961', 'nation':'ITALY' }
|
||||
);
|
||||
|
||||
INSERT INTO cycling.birthday_list (
|
||||
cyclist_name, blist
|
||||
) VALUES (
|
||||
'Laurence BOURQUE', { 'age':'23', 'bday':'27/07/1992', 'nation':'CANADA' }
|
||||
);
|
||||
|
||||
INSERT INTO cycling.birthday_list (
|
||||
cyclist_name, blist
|
||||
) VALUES (
|
||||
'Claudio HEINEN', { 'age':'23', 'bday':'27/07/1992', 'nation':'GERMANY' }
|
||||
);
|
||||
|
||||
INSERT INTO cycling.birthday_list (
|
||||
cyclist_name, blist
|
||||
) VALUES (
|
||||
'Luc HAGENAARS', { 'age':'28', 'bday':'27/07/1987', 'nation':'NETHERLANDS' }
|
||||
);
|
||||
|
||||
INSERT INTO cycling.birthday_list (
|
||||
cyclist_name, blist
|
||||
) VALUES (
|
||||
'Toine POELS', { 'age':'52', 'bday':'27/07/1963', 'nation':'NETHERLANDS' }
|
||||
);
|
||||
// end::insertentries[]
|
||||
|
||||
// Query entries - find cyclist same age
|
||||
CAPTURE 'select_from_birthday_list_where_age_23.result';
|
||||
// tag::ageentryquery[]
|
||||
SELECT *
|
||||
FROM cycling.birthday_list
|
||||
WHERE blist[ 'age' ] = '23';
|
||||
// end::ageentryquery[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// Query entries - find cyclist same nation map entry
|
||||
CAPTURE 'select_from_birthday_list_where_nation_netherlands.result';
|
||||
// tag::nationentryquery[]
|
||||
SELECT *
|
||||
FROM cycling.birthday_list
|
||||
WHERE blist[ 'nation' ] = 'NETHERLANDS';
|
||||
// end::nationentryquery[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// Query entries - find cyclist same nation with map VALUES CONTAINS
|
||||
CAPTURE 'select_from_birthday_list_where_nation_netherlands_2.result';
|
||||
// tag::nationvaluesquery[]
|
||||
SELECT *
|
||||
FROM cycling.birthday_list
|
||||
WHERE blist CONTAINS 'NETHERLANDS';
|
||||
// end::nationvaluesquery[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::dropentriesindex[]
|
||||
DROP INDEX IF EXISTS cycling.blist_idx;
|
||||
// end::dropentriesindex[]
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CREATE CUSTOM INDEX IF NOT EXISTS ann_index
|
||||
ON cycling.comments_vs(comment_vector) USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CREATE CUSTOM INDEX IF NOT EXISTS ann_index
|
||||
ON vsearch.products(item_vector) USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CREATE KEYSPACE IF NOT EXISTS cycling
|
||||
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' };
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CREATE KEYSPACE IF NOT EXISTS vsearch
|
||||
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : '1' };
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// tag::createvstable[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.comments_vs (
|
||||
record_id timeuuid,
|
||||
id uuid,
|
||||
commenter text,
|
||||
comment text,
|
||||
comment_vector VECTOR <FLOAT, 5>,
|
||||
created_at timestamp,
|
||||
PRIMARY KEY (id, created_at)
|
||||
)
|
||||
WITH CLUSTERING ORDER BY (created_at DESC);
|
||||
// end::createvstable[]
|
||||
|
||||
// tag::altervstable[]
|
||||
ALTER TABLE cycling.comments_vs
|
||||
ADD comment_vector VECTOR <FLOAT, 5>; //<1>
|
||||
// end::altervstable[]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
CREATE TABLE IF NOT EXISTS cycling.products (
|
||||
id int PRIMARY KEY,
|
||||
name TEXT,
|
||||
description TEXT,
|
||||
item_vector VECTOR<FLOAT, 5> //<1>
|
||||
);
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP TABLE IF EXISTS cycling.cyclist_career_teams;
|
||||
|
||||
// Find all teams that a cyclist has been a member of
|
||||
// CREATE TABLE WITH SET
|
||||
// tag::setColumn[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.cyclist_career_teams (
|
||||
id UUID PRIMARY KEY,
|
||||
lastname text,
|
||||
teams set<text>
|
||||
);
|
||||
// end::setColumn[]
|
||||
|
||||
DROP INDEX IF EXISTS cycling.teams_idx;
|
||||
|
||||
// Create an index on the set collection
|
||||
// tag::createidxset[]
|
||||
CREATE INDEX IF NOT EXISTS teams_idx
|
||||
ON cycling.cyclist_career_teams (teams);
|
||||
// end::createidxset[]
|
||||
|
||||
// tag::insertdatasetvos[]
|
||||
INSERT INTO cycling.cyclist_career_teams (
|
||||
id, lastname, teams
|
||||
) VALUES (
|
||||
5b6962dd-3f90-4c93-8f61-eabfa4a803e2,
|
||||
'VOS',
|
||||
{
|
||||
'Rabobank-Liv Woman Cycling Team',
|
||||
'Rabobank-Liv Giant',
|
||||
'Rabobank Women Team',
|
||||
'Nederland bloeit'
|
||||
}
|
||||
);
|
||||
// end::insertdatasetvos[]
|
||||
|
||||
INSERT INTO cycling.cyclist_career_teams (id,lastname,teams) VALUES (e7cd5752-bc0d-4157-a80f-7523add8dbcd, 'VAN DER BREGGEN', { 'Rabobank-Liv Woman Cycling Team','Sengers Ladies Cycling Team','Team Flexpoint' } );
|
||||
INSERT INTO cycling.cyclist_career_teams (id,lastname,teams) VALUES (cb07baad-eac8-4f65-b28a-bddc06a0de23, 'ARMITSTEAD', { 'Boels-Dolmans Cycling Team','AA Drink - Leontien.nl','Team Garmin - Cervelo' } );
|
||||
INSERT INTO cycling.cyclist_career_teams (id,lastname,teams) VALUES (1c9ebc13-1eab-4ad5-be87-dce433216d40, 'BRAND', { 'Rabobank-Liv Woman Cycling Team','Rabobank-Liv Giant','AA Drink - Leontien.nl','Leontien.nl' } );
|
||||
|
||||
CAPTURE 'select_all_from_cyclist_career_teams.result';
|
||||
// tag::select[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_career_teams;
|
||||
// end::select[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::add[]
|
||||
UPDATE cycling.cyclist_career_teams
|
||||
SET teams = teams + {'Team DSB - Ballast Nedam'}
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
// end::add[]
|
||||
|
||||
// tag::remove[]
|
||||
UPDATE cycling.cyclist_career_teams
|
||||
SET teams = teams - {'DSB Bank Nederland bloeit'}
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
// end::remove[]
|
||||
|
||||
// tag::clear[]
|
||||
UPDATE cycling.cyclist_career_teams
|
||||
SET teams = {}
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
|
||||
DELETE teams
|
||||
FROM cycling.cyclist_career_teams
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
// end::clear[]
|
||||
|
||||
CAPTURE 'select_from_cyclist_career_teams_empty.result';
|
||||
// tag::selectwithpartitionkey[]
|
||||
SELECT id, lastname, teams
|
||||
FROM cycling.cyclist_career_teams
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
// end::selectwithpartitionkey[]
|
||||
CAPTURE OFF;
|
||||
|
||||
CAPTURE 'select_all_from_cyclist_career_teams_contains_value.result';
|
||||
// tag::select_with_contains_value[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_career_teams
|
||||
WHERE teams CONTAINS 'Rabobank-Liv Giant';
|
||||
// end::select_with_contains_value[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::select_with_contains_key[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_career_teams
|
||||
WHERE teams CONTAINS 'Rabobank-Liv Giant';
|
||||
// end::select_with_contains_key[]
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP TABLE IF EXISTS cycling.cyclist_races;
|
||||
|
||||
// Find all races for a particular cyclist
|
||||
// CREATE TYPE - User-Defined Type, race
|
||||
// CREATE TABLE WITH LIST, SIMPLE PRIMARY KEY
|
||||
SOURCE 'race-type.cql';
|
||||
|
||||
// tag::frozenlist[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.cyclist_races (
|
||||
id UUID PRIMARY KEY,
|
||||
lastname text,
|
||||
firstname text,
|
||||
races list<FROZEN <race>>
|
||||
);
|
||||
// end::frozenlist[]
|
||||
|
||||
// tag::insertFL[]
|
||||
INSERT INTO cycling.cyclist_races (
|
||||
id,
|
||||
lastname,
|
||||
firstname,
|
||||
races
|
||||
) VALUES (
|
||||
5b6962dd-3f90-4c93-8f61-eabfa4a803e2,
|
||||
'VOS',
|
||||
'Marianne',
|
||||
[ {
|
||||
race_title:'Rabobank 7-Dorpenomloop Aalburg',
|
||||
race_date:'2015-05-09',
|
||||
race_time:'02:58:33'},
|
||||
{
|
||||
race_title:'Ronde van Gelderland',
|
||||
race_date:'2015-04-19',
|
||||
race_time:'03:22:23'
|
||||
}
|
||||
]
|
||||
);
|
||||
// end::insertFL[]
|
||||
|
||||
INSERT INTO cycling.cyclist_races (
|
||||
id, lastname, firstname, races
|
||||
) VALUES (
|
||||
e7cd5752-bc0d-4157-a80f-7523add8dbcd, 'VAN DER BREGGEN', 'Anna', [ {race_title:'Festival Luxembourgeois du cyclisme feminin Elsy Jacobs - Prologue - Garnich > Garnich',race_date:'2015-05-01',race_time:'08:13:00'},{race_title:'Festival Luxembourgeois du cyclisme feminin Elsy Jacobs - Stage 2 - Garnich > Garnich',race_date:'2015-05-02',race_time:'02:41:52'},{race_title:'Festival Luxembourgeois du cyclisme feminin Elsy Jacobs - Stage 3 - Mamer > Mamer',race_date:'2015-05-03',race_time:'02:31:24'} ]
|
||||
);
|
||||
|
||||
// tag::add[]
|
||||
ALTER TABLE cycling.cyclist_races
|
||||
ADD manager UUID;
|
||||
// end::add[]
|
||||
|
||||
// tag::list[]
|
||||
ALTER TABLE cycling.cyclist_races
|
||||
ADD completed list<text>;
|
||||
// end::list[]
|
||||
|
||||
// tag::drop[]
|
||||
ALTER TABLE cycling.cyclist_races
|
||||
DROP manager;
|
||||
// end::drop[]
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP TABLE IF EXISTS cycling.cyclist_semi_pro;
|
||||
|
||||
// tag::createCyclistSemiProTable[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.cyclist_semi_pro (
|
||||
id int,
|
||||
firstname text,
|
||||
lastname text,
|
||||
age int,
|
||||
affiliation text,
|
||||
country text,
|
||||
registration date,
|
||||
PRIMARY KEY (id));
|
||||
// end::createCyclistSemiProTable[]
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::createQuickStartIndices[]
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (1, 'Carlos', 'Perotti', 22, 'Recco Club', 'ITA', '2020-01-12');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (2, 'Giovani', 'Pasi', 19, 'Venezia Velocità', 'ITA', '2016-05-15');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (3, 'Frances', 'Giardello', 24, 'Menaggio Campioni', 'ITA', '2018-07-29');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (4, 'Mark', 'Pastore', 19, 'Portofino Ciclisti', 'ITA', '2017-06-16');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (5, 'Irene', 'Cantona', 24, 'Como Velocità', 'ITA', '2012-07-22');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (6, 'Hugo', 'Herrera', 23, 'Bellagio Ciclisti', 'ITA', '2004-02-12');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (7, 'Marcel', 'Silva', 21, 'Paris Cyclistes', 'FRA', '2018-04-28');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (8, 'Theo', 'Bernat', 19, 'Nice Cavaliers', 'FRA', '2007-05-15');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (9, 'Richie', 'Draxler', 24, 'Normandy Club', 'FRA', '2011-02-26');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (10, 'Agnes', 'Cavani', 22, 'Chamonix Hauteurs', 'FRA', '2020-01-02');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (11, 'Pablo', 'Verratti', 19, 'Chamonix Hauteurs', 'FRA', '2006-05-15');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (12, 'Charles', 'Eppinger', 24, 'Chamonix Hauteurs', 'FRA', '2018-07-29');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (13, 'Stanley', 'Trout', 30, 'Bolder Boulder', 'USA', '2016-02-12');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (14, 'Juan', 'Perez', 31, 'Rutgers Alumni Riders', 'USA', '2017-06-16');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (15, 'Thomas', 'Fulton', 27, 'Exeter Academy', 'USA', '2012-12-15');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (16, 'Jenny', 'Hamler', 28, 'CU Alums Crankworkz', 'USA', '2012-07-22');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (17, 'Alice', 'McCaffrey', 26, 'Pennan Power', 'GBR', '2020-02-12');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (18, 'Nicholas', 'Burrow', 26, 'Aberdeen Association', 'GBR', '2016-02-12');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (19, 'Tyler', 'Higgins', 24, 'Highclere Agents', 'GBR', '2019-07-31');
|
||||
INSERT INTO cycling.cyclist_semi_pro (id, firstname, lastname, age, affiliation, country, registration) VALUES (20, 'Leslie', 'Boyd', 18, 'London Cyclists', 'GBR', '2012-12-15');
|
||||
// end::createQuickStartIndices[]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP INDEX IF EXISTS cycling.lastname_sai_idx;
|
||||
DROP INDEX IF EXISTS cycling.age_sai_idx;
|
||||
DROP INDEX IF EXISTS cycling.country_sai_idx;
|
||||
DROP INDEX IF EXISTS cycling.registration_sai_idx;
|
||||
|
||||
// tag::createQuickStartIndices[]
|
||||
CREATE CUSTOM INDEX lastname_sai_idx ON cycling.cyclist_semi_pro (lastname)
|
||||
USING 'StorageAttachedIndex'
|
||||
WITH OPTIONS = {'case_sensitive': 'false', 'normalize': 'true', 'ascii': 'true'};
|
||||
|
||||
CREATE CUSTOM INDEX age_sai_idx ON cycling.cyclist_semi_pro (age)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
||||
CREATE CUSTOM INDEX country_sai_idx ON cycling.cyclist_semi_pro (country)
|
||||
USING 'StorageAttachedIndex'
|
||||
WITH OPTIONS = {'case_sensitive': 'false', 'normalize': 'true', 'ascii': 'true'};
|
||||
|
||||
CREATE CUSTOM INDEX registration_sai_idx ON cycling.cyclist_semi_pro (registration)
|
||||
USING 'StorageAttachedIndex';
|
||||
// end::createQuickStartIndices[]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::cyclistSelectAge[]
|
||||
SELECT * FROM cycling.cyclist_semi_pro WHERE age <= 23;
|
||||
// end::cyclistSelectAge[]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::cyclistSelectCountry[]
|
||||
SELECT * FROM cycling.cyclist_semi_pro WHERE country = 'GBR';
|
||||
// end::cyclistSelectCountry[]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::cyclistSelectDateRange[]
|
||||
SELECT * FROM cycling.cyclist_semi_pro WHERE registration > '2010-01-01' AND registration < '2015-12-31' LIMIT 10;
|
||||
// end::cyclistSelectDateRange[]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::cyclistSelectSpecificRider[]
|
||||
SELECT * FROM cycling.cyclist_semi_pro WHERE lastname = 'Eppinger';
|
||||
// end::cyclistSelectSpecificRider[]
|
||||
|
|
@ -0,0 +1,120 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP TABLE IF EXISTS cycling.cyclist_teams;
|
||||
|
||||
// Create a table with a map
|
||||
// tag::mapColumn[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.cyclist_teams (
|
||||
id uuid PRIMARY KEY,
|
||||
firstname text,
|
||||
lastname text,
|
||||
teams map<int, text>
|
||||
);
|
||||
// end::mapColumn[]
|
||||
|
||||
DROP INDEX IF EXISTS cycling.team_year_idx;
|
||||
|
||||
// Create an index on a map key to find all cyclist/team combos for a year
|
||||
// tag::keysidx[]
|
||||
CREATE INDEX IF NOT EXISTS team_year_keys_idx
|
||||
ON cycling.cyclist_teams ( KEYS (teams) );
|
||||
// end::keysidx[]
|
||||
|
||||
// Create an index on a map key to find all cyclist/team combos for a year
|
||||
// tag::valuesidx[]
|
||||
CREATE INDEX IF NOT EXISTS team_year_values_idx
|
||||
ON cycling.cyclist_teams ( VALUES (teams) );
|
||||
// end::valuesidx[]
|
||||
|
||||
// Create an index on a map key to find all cyclist/team combos for a year
|
||||
// tag::entriesidx[]
|
||||
CREATE INDEX IF NOT EXISTS team_year_entries_idx
|
||||
ON cycling.cyclist_teams ( ENTRIES (teams) );
|
||||
// end::entriesidx[]
|
||||
|
||||
// Insert team data into map for cyclist Vos
|
||||
// tag::insertmapdata[]
|
||||
INSERT INTO cycling.cyclist_teams (
|
||||
id, firstname, lastname, teams
|
||||
) VALUES (
|
||||
5b6962dd-3f90-4c93-8f61-eabfa4a803e2,
|
||||
'Marianne',
|
||||
'VOS',
|
||||
{
|
||||
2015 : 'Rabobank-Liv Woman Cycling Team',
|
||||
2014 : 'Rabobank-Liv Woman Cycling Team'
|
||||
}
|
||||
);
|
||||
// end::insertmapdata[]
|
||||
|
||||
// View data
|
||||
CAPTURE 'select_all_from_cyclist_teams.result';
|
||||
// tag::select[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_teams;
|
||||
// end::select[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// Delete an element from the map
|
||||
// tag::deletemapdata[]
|
||||
DELETE teams[2014]
|
||||
FROM cycling.cyclist_teams
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
// end::deletemapdata[]
|
||||
|
||||
// View data again, 2014 team gone
|
||||
SELECT *
|
||||
FROM cycling.cyclist_teams;
|
||||
|
||||
// Insert more cyclists
|
||||
INSERT INTO cycling.cyclist_teams (
|
||||
id,firstname,lastname,teams
|
||||
) VALUES (
|
||||
cb07baad-eac8-4f65-b28a-bddc06a0de23,
|
||||
'Elizabeth',
|
||||
'ARMITSTEAD',
|
||||
{
|
||||
2015 : 'Boels:Dolmans Cycling Team',
|
||||
2014 : 'Boels:Dolmans Cycling Team',
|
||||
2013 : 'Boels:Dolmans Cycling Team',
|
||||
2012 : 'AA Drink - Leontien.nl',
|
||||
2011 : 'Team Garmin - Cervelo'
|
||||
}
|
||||
);
|
||||
|
||||
// View data
|
||||
SELECT *
|
||||
FROM cycling.cyclist_teams;
|
||||
|
||||
// Query for KEY year 2015
|
||||
CAPTURE 'cyclist_team-queries.result';
|
||||
// tag::queryindexkey[]
|
||||
SELECT *
|
||||
FROM cycling.cyclist_teams
|
||||
WHERE teams CONTAINS KEY 2015;
|
||||
// end::queryindexkey[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::update_DSB[]
|
||||
UPDATE cycling.cyclist_teams
|
||||
SET teams = teams + { 2009 : 'DSB Bank - Nederland bloeit' }
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
// end::update_DSB[]
|
||||
|
||||
// tag::update_Ballast[]
|
||||
UPDATE cycling.cyclist_teams
|
||||
SET teams[2006] = 'Team DSB - Ballast Nedam'
|
||||
WHERE id = 5b6962dd-3f90-4c93-8f61-eabfa4a803e2;
|
||||
// end::update_Ballast[]
|
||||
|
||||
// tag::delete_teams[]
|
||||
DELETE teams[2009]
|
||||
FROM cycling.cyclist_teams
|
||||
WHERE id=e7cd5752-bc0d-4157-a80f-7523add8dbcd;
|
||||
// end::delete_teams[]
|
||||
|
||||
// tag::update_set[]
|
||||
UPDATE cycling.cyclist_teams
|
||||
SET teams = teams - { 2013, 2014 }
|
||||
WHERE id = e7cd5752-bc0d-4157-a80f-7523add8dbcd;
|
||||
// end::update_set[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
DROP INDEX IF EXISTS cycling.lastname_sai_idx;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
CREATE CUSTOM INDEX commenter_cs_idx ON cycling.comments_vs (commenter)
|
||||
USING 'StorageAttachedIndex'
|
||||
WITH OPTIONS = {'case_sensitive': 'true', 'normalize': 'true', 'ascii': 'true'};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
CREATE CUSTOM INDEX race_name_idx
|
||||
ON cycling.rank_by_year_and_name (race_name)
|
||||
USING 'StorageAttachedIndex';
|
||||
CREATE CUSTOM INDEX race_year_idx
|
||||
ON cycling.rank_by_year_and_name (race_year)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
CREATE CUSTOM INDEX events_idx
|
||||
ON cycling.upcoming_calendar (events)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
// Create an index on a map key to find all cyclist/team combos for a year
|
||||
// tag::keysidx[]
|
||||
CREATE INDEX IF NOT EXISTS team_year_keys_idx
|
||||
ON cycling.cyclist_teams ( KEYS (teams) );
|
||||
// end::keysidx[]
|
||||
|
||||
// Create an index on a map key to find all cyclist/team combos for a year
|
||||
// tag::valuesidx[]
|
||||
CREATE INDEX IF NOT EXISTS team_year_values_idx
|
||||
ON cycling.cyclist_teams ( VALUES (teams) );
|
||||
// end::valuesidx[]
|
||||
|
||||
// Create an index on a map key to find all cyclist/team combos for a year
|
||||
// tag::entriesidx[]
|
||||
CREATE INDEX IF NOT EXISTS team_year_entries_idx
|
||||
ON cycling.cyclist_teams ( ENTRIES (teams) );
|
||||
// end::entriesidx[]
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
CREATE CUSTOM INDEX teams_idx
|
||||
ON cycling.cyclist_career_teams (teams)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
CREATE CUSTOM INDEX commenter_idx
|
||||
ON cycling.comments_vs (commenter)
|
||||
USING 'StorageAttachedIndex';
|
||||
CREATE CUSTOM INDEX created_at_idx
|
||||
ON cycling.comments_vs (created_at)
|
||||
USING 'StorageAttachedIndex';
|
||||
CREATE CUSTOM INDEX ann_index
|
||||
ON cycling.comments_vs (comment_vector)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT * FROM comments_vs WHERE commenter ='alex';
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT comment,commenter FROM comments_vs WHERE commenter ='Alex';
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SELECT * FROM cycling.rank_by_year_and_name
|
||||
WHERE race_name = 'Tour of Japan - Stage 4 - Minami > Shinshu';
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SELECT * FROM cycling.rank_by_year_and_name
|
||||
WHERE race_year = 2014;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SELECT * FROM cycling.upcoming_calendar
|
||||
WHERE events CONTAINS 'Criterium du Dauphine'
|
||||
OR month = 7;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SELECT * FROM cycling.upcoming_calendar
|
||||
WHERE events CONTAINS 'Criterium du Dauphine';
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
SELECT * FROM cyclist_teams
|
||||
WHERE
|
||||
teams[2014] = 'Boels:Dolmans Cycling Team'
|
||||
AND teams[2015] = 'Boels:Dolmans Cycling Team';
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT * FROM cyclist_teams WHERE teams CONTAINS KEY 2014;
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT * FROM cyclist_teams WHERE teams CONTAINS 'Team Garmin - Cervelo';
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SELECT * FROM cycling.cyclist_career_teams
|
||||
WHERE teams CONTAINS 'Rabobank-Liv Giant';
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
SELECT * FROM cycling.comments_vs
|
||||
WHERE
|
||||
created_at='2017-03-21 21:11:09.999000+0000'
|
||||
AND commenter = 'Alex';
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
SELECT * FROM cycling.comments_vs
|
||||
WHERE created_at IN
|
||||
('2017-03-21 21:11:09.999000+0000'
|
||||
,'2017-03-22 01:16:59.001000+0000');
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
SELECT * FROM cycling.comments_vs
|
||||
WHERE
|
||||
created_at='2017-03-21 21:11:09.999000+0000'
|
||||
OR created_at='2017-03-22 01:16:59.001000+0000';
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
SELECT * FROM cycling.comments_vs
|
||||
WHERE commenter = 'Alex';
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
SELECT * FROM cycling.cyclist_races
|
||||
WHERE races CONTAINS {
|
||||
race_title:'Rabobank 7-Dorpenomloop Aalburg',
|
||||
race_date:'2015-05-09',
|
||||
race_time:'02:58:33'};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
CREATE CUSTOM INDEX sim_comments_idx
|
||||
ON cycling.comments_vs (comment_vector)
|
||||
USING 'StorageAttachedIndex'
|
||||
WITH OPTIONS = { 'similarity_function': 'DOT_PRODUCT'};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
CREATE CUSTOM INDEX commenter_idx
|
||||
ON cycling.comments_vs (commenter)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
CREATE CUSTOM INDEX races_idx
|
||||
ON cycling.cyclist_races (races)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
INSERT INTO cycling.comments_vs (record_id, id, created_at, comment, commenter, comment_vector
|
||||
VALUES (
|
||||
now(),
|
||||
e7ae5cf3-d358-4d99-b900-85902fda9bb0,
|
||||
'2017-02-14 12:43:20-0800',
|
||||
'Raining too hard should have postponed',
|
||||
'Alex',
|
||||
[0.45, 0.09, 0.01, 0.2, 0.11]
|
||||
);
|
||||
INSERT INTO cycling.comments_vs (record_id, id, created_at, comment, commenter, comment_vector)
|
||||
VALUES (
|
||||
now(),
|
||||
e7ae5cf3-d358-4d99-b900-85902fda9bb0,
|
||||
'2017-03-21 13:11:09.999-0800',
|
||||
'Second rest stop was out of water',
|
||||
'Alex',
|
||||
[0.99, 0.5, 0.99, 0.1, 0.34]
|
||||
);
|
||||
INSERT INTO cycling.comments_vs (record_id, id, created_at, comment, commenter, comment_vector)
|
||||
VALUES (
|
||||
now(),
|
||||
e7ae5cf3-d358-4d99-b900-85902fda9bb0,
|
||||
'2017-04-01 06:33:02.16-0800',
|
||||
'LATE RIDERS SHOULD NOT DELAY THE START',
|
||||
'Alex',
|
||||
[0.9, 0.54, 0.12, 0.1, 0.95]
|
||||
);
|
||||
|
||||
INSERT INTO cycling.comments_vs (record_id, id, created_at, comment, commenter, comment_vector)
|
||||
VALUES (
|
||||
now(),
|
||||
c7fceba0-c141-4207-9494-a29f9809de6f,
|
||||
totimestamp(now()),
|
||||
'The gift certificate for winning was the best',
|
||||
'Amy',
|
||||
[0.13, 0.8, 0.35, 0.17, 0.03]
|
||||
);
|
||||
|
||||
INSERT INTO cycling.comments_vs (record_id, id, created_at, comment, commenter, comment_vector)
|
||||
VALUES (
|
||||
now(),
|
||||
c7fceba0-c141-4207-9494-a29f9809de6f,
|
||||
'2017-02-17 12:43:20.234+0400',
|
||||
'Glad you ran the race in the rain',
|
||||
'Amy',
|
||||
[0.3, 0.34, 0.2, 0.78, 0.25]
|
||||
);
|
||||
|
||||
INSERT INTO cycling.comments_vs (record_id, id, created_at, comment, commenter, comment_vector)
|
||||
VALUES (
|
||||
now(),
|
||||
c7fceba0-c141-4207-9494-a29f9809de6f,
|
||||
'2017-03-22 5:16:59.001+0400',
|
||||
'Great snacks at all reststops',
|
||||
'Amy',
|
||||
[0.1, 0.4, 0.1, 0.52, 0.09]
|
||||
);
|
||||
INSERT INTO cycling.comments_vs (record_id, id, created_at, comment, commenter, comment_vector)
|
||||
VALUES (
|
||||
now(),
|
||||
c7fceba0-c141-4207-9494-a29f9809de6f,
|
||||
'2017-04-01 17:43:08.030+0400',
|
||||
'Last climb was a killer',
|
||||
'Amy',
|
||||
[0.3, 0.75, 0.2, 0.2, 0.5]
|
||||
);
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// tag::drop[]
|
||||
DROP TYPE IF EXISTS cycling.race;
|
||||
// end::drop[]
|
||||
|
||||
// tag::racetype[]
|
||||
CREATE TYPE IF NOT EXISTS cycling.race (
|
||||
race_title text,
|
||||
race_date timestamp,
|
||||
race_time text
|
||||
);
|
||||
// end::racetype[]
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP TABLE IF EXISTS cycling.race_starts;
|
||||
|
||||
// create a table with a frozen list of ints
|
||||
// tag::frozenlist[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.race_starts (
|
||||
cyclist_name text PRIMARY KEY,
|
||||
rnumbers FROZEN<LIST<int>>
|
||||
);
|
||||
// end::frozenlist[]
|
||||
|
||||
// View created table
|
||||
DESCRIBE TABLE cycling.race_starts;
|
||||
|
||||
DROP INDEX IF EXISTS cycling.rnumbers_idx;
|
||||
|
||||
// Create index
|
||||
// tag::fullindex[]
|
||||
CREATE INDEX IF NOT EXISTS rnumbers_idx
|
||||
ON cycling.race_starts ( FULL(rnumbers) );
|
||||
// end::fullindex[]
|
||||
|
||||
// Insert data
|
||||
INSERT INTO cycling.race_starts (
|
||||
cyclist_name, rnumbers
|
||||
) VALUES (
|
||||
'John DEGENKOLB', [39, 7, 14]
|
||||
);
|
||||
|
||||
// Select data with WHERE clause
|
||||
CAPTURE 'race_starts-queries.result';
|
||||
// tag::selectrnumbers[]
|
||||
SELECT *
|
||||
FROM cycling.race_starts
|
||||
WHERE rnumbers = [39, 7, 14];
|
||||
// end::selectrnumbers[]
|
||||
CAPTURE OFF;
|
||||
|
|
@ -0,0 +1,134 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP TABLE IF EXISTS cycling.rank_by_year_and_name;
|
||||
|
||||
// Store race information by year and race name using a COMPOSITE PARTITION KEY
|
||||
|
||||
// tag::use_and_compositepk[]
|
||||
USE cycling;
|
||||
CREATE TABLE rank_by_year_and_name (
|
||||
race_year int,
|
||||
race_name text,
|
||||
cyclist_name text,
|
||||
rank int,
|
||||
PRIMARY KEY ((race_year, race_name), rank)
|
||||
);
|
||||
// end::use_and_compositepk[]
|
||||
|
||||
DROP TABLE IF EXISTS cycling.rank_by_year_and_name;
|
||||
|
||||
// tag::compositepk[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.rank_by_year_and_name (
|
||||
race_year int,
|
||||
race_name text,
|
||||
cyclist_name text,
|
||||
rank int,
|
||||
PRIMARY KEY ((race_year, race_name), rank)
|
||||
);
|
||||
// end::compositepk[]
|
||||
|
||||
// tag::dropindex[]
|
||||
DROP INDEX IF EXISTS cycling.rank_idx;
|
||||
// end::dropindex[]
|
||||
|
||||
// tag::createindex[]
|
||||
CREATE INDEX IF NOT EXISTS rank_idx
|
||||
ON cycling.rank_by_year_and_name (rank);
|
||||
// end::createindex[]
|
||||
|
||||
// tag::drop_race_year_idx[]
|
||||
DROP INDEX IF EXISTS cycling.race_year_idx;
|
||||
// end::drop_race_year_idx[]
|
||||
|
||||
// tag::create_race_year_idx[]
|
||||
CREATE INDEX IF NOT EXISTS race_year_idx ON
|
||||
cycling.rank_by_year_and_name (race_year);
|
||||
// end::create_race_year_idx[]
|
||||
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Benjamin PRADES', 1);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Adam PHELAN', 2);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Thomas LEBAS', 3);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Benjamin PRADES', 3);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Daniel MARTIN', 1);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, 'Tour of Japan - Stage 4 - Minami > Shinshu', 'Johan Esteban CHAVES', 2);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Giro d''Italia - Stage 11 - Forli > Imola', 'Ilnur ZAKARIN', 1);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2015, 'Giro d''Italia - Stage 11 - Forli > Imola', 'Carlos BETANCUR', 2);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Phillippe GILBERT', 1);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Daniel MARTIN', 2);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Johan Esteban CHAVES', 3);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Phillippe GILBERT', 1);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Daniel MARTIN', 2);
|
||||
INSERT INTO cycling.rank_by_year_and_name (race_year, race_name, cyclist_name, rank) VALUES (2014, '4th Tour of Beijing', 'Johan Esteban CHAVES', 3);
|
||||
|
||||
// Show all inserted data
|
||||
CAPTURE 'select_all_from_rank_by_year_and_name.result';
|
||||
SELECT *
|
||||
FROM cycling.rank_by_year_and_name;
|
||||
CAPTURE OFF;
|
||||
|
||||
CAPTURE 'select_all_from_rank_by_year_and_name_Japan_2014.result';
|
||||
// tag::select_with_name_and_year[]
|
||||
SELECT *
|
||||
FROM cycling.rank_by_year_and_name
|
||||
WHERE race_year = 2014
|
||||
AND race_name = 'Tour of Japan - Stage 4 - Minami > Shinshu';
|
||||
// end::select_with_name_and_year[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::sepstatementswithand[]
|
||||
SELECT
|
||||
rank,
|
||||
cyclist_name AS name
|
||||
FROM cycling.rank_by_year_and_name
|
||||
WHERE "race_name" = 'Tour of Japan - Stage 4 - Minami > Shinshu'
|
||||
AND race_year = 2014;
|
||||
// end::sepstatementswithand[]
|
||||
|
||||
// tag::columnalias[]
|
||||
CAPTURE 'select_best_rank_from_rank_by_year_and_name.result';
|
||||
SELECT
|
||||
MIN(rank) AS best_rank,
|
||||
cyclist_name
|
||||
FROM cycling.rank_by_year_and_name
|
||||
WHERE "race_name" = 'Tour of Japan - Stage 4 - Minami > Shinshu'
|
||||
AND race_year = 2014;
|
||||
// end::columnalias[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// The following query generates a warning, which is normal
|
||||
// tag::countrows[]
|
||||
SELECT COUNT(*)
|
||||
FROM cycling.rank_by_year_and_name;
|
||||
// end::countrows[]
|
||||
|
||||
// tag::limitrows[]
|
||||
SELECT cyclist_name
|
||||
FROM cycling.rank_by_year_and_name
|
||||
LIMIT 50000;
|
||||
// end::limitrows[]
|
||||
|
||||
// Query by partition
|
||||
CAPTURE 'select_all_from_rank_by_year_and_name_partition_limit.result';
|
||||
// tag::partlimit[]
|
||||
SELECT *
|
||||
FROM cycling.rank_by_year_and_name
|
||||
PER PARTITION LIMIT 2;
|
||||
// end::partlimit[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// Select rank - filter on a clustering column
|
||||
CAPTURE 'select_all_from_rank_by_year_and_name_rank_1.result';
|
||||
// tag::selectrank[]
|
||||
SELECT *
|
||||
FROM cycling.rank_by_year_and_name
|
||||
WHERE rank = 1;
|
||||
// end::selectrank[]
|
||||
CAPTURE OFF;
|
||||
|
||||
CAPTURE 'select_all_from_rank_by_year_and_name_2014.result';
|
||||
// tag::select_with_year[]
|
||||
SELECT *
|
||||
FROM cycling.rank_by_year_and_name
|
||||
WHERE race_year = 2014;
|
||||
// end::select_with_year[]
|
||||
CAPTURE OFF;
|
||||
|
|
@ -0,0 +1 @@
|
|||
DESCRIBE TABLE cycling.cyclist_semi_pro;
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
CREATE CUSTOM INDEX ON demo2.person_id_name_primarykey (id)
|
||||
USING 'StorageAttachedIndex';
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
SELECT * FROM cycling.comments_vs
|
||||
ORDER BY comment_vector ANN OF [0.15, 0.1, 0.1, 0.35, 0.55]
|
||||
LIMIT 3;
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT * FROM cyclist_career_teams WHERE teams CONTAINS 'Rabobank-Liv Woman Cycling Team';
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT * FROM rank_by_year_and_name WHERE rank = 1;
|
||||
|
|
@ -0,0 +1,145 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
DROP TABLE IF EXISTS cycling.upcoming_calendar;
|
||||
|
||||
// Find all calendar events for a particular year and month
|
||||
// tag::listColumn[]
|
||||
CREATE TABLE IF NOT EXISTS cycling.upcoming_calendar (
|
||||
year int,
|
||||
month int,
|
||||
events list<text>,
|
||||
PRIMARY KEY (year, month)
|
||||
);
|
||||
// end::listColumn[]
|
||||
|
||||
// tag::add_tour[]
|
||||
INSERT INTO cycling.upcoming_calendar (
|
||||
year, month, events
|
||||
) VALUES (
|
||||
2015, 06, [ 'Criterium du Dauphine', 'Tour de Suisse' ]
|
||||
);
|
||||
// end::add_tour[]
|
||||
|
||||
INSERT INTO cycling.upcoming_calendar (
|
||||
year, month, events
|
||||
) VALUES (
|
||||
2015, 07, [ 'Tour de France' ]
|
||||
);
|
||||
|
||||
// tag::delete[]
|
||||
DELETE events[0]
|
||||
FROM cycling.upcoming_calendar
|
||||
WHERE year = 2015
|
||||
AND month = 07;
|
||||
// end::delete[]
|
||||
|
||||
// tag::remove[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET events = events - ['Tour de France Stage 10']
|
||||
WHERE year = 2015
|
||||
AND month = 07;
|
||||
// end::remove[]
|
||||
|
||||
INSERT INTO cycling.upcoming_calendar (
|
||||
year, month, events
|
||||
) VALUES (
|
||||
2015, 07, [ 'Tour de France' ]
|
||||
);
|
||||
|
||||
CAPTURE 'select_all_from_upcoming_calendar.result';
|
||||
// tag::select[]
|
||||
SELECT *
|
||||
FROM cycling.upcoming_calendar;
|
||||
// end::select[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::insert[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET events = [ 'Criterium du Dauphine', 'Tour de Suisse' ]
|
||||
WHERE year = 2015
|
||||
AND month = 06;
|
||||
// end::insert[]
|
||||
|
||||
// tag::prepend[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET events = [ 'Tour de France' ] + events
|
||||
WHERE year = 2015
|
||||
AND month = 06;
|
||||
// end::prepend[]
|
||||
|
||||
// tag::append[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET events = events + [ 'Tour de France' ]
|
||||
WHERE year = 2017
|
||||
AND month = 05;
|
||||
// end::append[]
|
||||
|
||||
// tag::position[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET events[2] = 'Tour de France'
|
||||
WHERE year = 2015
|
||||
AND month = 06;
|
||||
// end::position[]
|
||||
|
||||
// tag::set[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET events[2] = 'Vuelta Ciclista a Venezuela'
|
||||
WHERE year = 2015
|
||||
AND month = 06;
|
||||
// end::set[]
|
||||
|
||||
// tag::ttl[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
USING TTL 10000000
|
||||
SET events[2] = 'Vuelta Ciclista a Venezuela'
|
||||
WHERE year = 2015
|
||||
AND month = 06;
|
||||
// end::ttl[]
|
||||
|
||||
// tag::addcolumn[]
|
||||
ALTER TABLE cycling.upcoming_calendar
|
||||
ADD description map<text,text>;
|
||||
// end::addcolumn[]
|
||||
|
||||
// tag::example[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET description = description + {
|
||||
'Criterium du Dauphine' : 'Easy race', 'Tour du Suisse' : 'Hard uphill race'
|
||||
}
|
||||
WHERE year = 2015
|
||||
AND month = 6;
|
||||
// end::example[]
|
||||
|
||||
// tag::newrow[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET description = {
|
||||
'Criterium du Dauphine' : 'Easy race', 'Tour du Suisse' : 'Hard uphill race'
|
||||
}
|
||||
WHERE year = 2015
|
||||
AND month = 6;
|
||||
// end::newrow[]
|
||||
|
||||
CAPTURE 'select_description_from_upcoming_calendar.result';
|
||||
// tag::select_description[]
|
||||
SELECT description
|
||||
FROM cycling.upcoming_calendar
|
||||
WHERE year = 2015
|
||||
AND month = 6;
|
||||
// end::select_description[]
|
||||
CAPTURE OFF;
|
||||
|
||||
// tag::value[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET events = events - [ 'Tour de France' ]
|
||||
WHERE year = 2015
|
||||
AND month = 06;
|
||||
// end::value[]
|
||||
|
||||
// tag::map[]
|
||||
UPDATE cycling.upcoming_calendar
|
||||
SET description = description + {
|
||||
'Criterium du Dauphine' : 'Easy race'
|
||||
}
|
||||
WHERE year = 2015
|
||||
AND month = 06;
|
||||
// end::map[]
|
||||
|
|
@ -0,0 +1 @@
|
|||
USE cycling;
|
||||
|
|
@ -0,0 +1 @@
|
|||
SELECT * FROM store.shopping_cart;
|
||||
|
|
@ -0,0 +1 @@
|
|||
TBD
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
id | birthday | first_race | height | last_race | lastname | nationality | w_units | weight
|
||||
--------------------------------------+------------+------------+--------+------------+----------+-------------+---------+--------
|
||||
e0953617-07eb-4c82-8f91-3b2757981625 | 1982-01-29 | 1998-02-15 | 1.78 | 2017-04-16 | BRUTT | Russia | kg | 68
|
||||
|
||||
(1 rows)
|
||||
|
|
@ -0,0 +1 @@
|
|||
28757dde589f70410f9a6a95c39ee7e6cde63440e2b06b91ae6b200614fa364d
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
id | firstname | lastname | teams
|
||||
--------------------------------------+-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
cb07baad-eac8-4f65-b28a-bddc06a0de23 | Elizabeth | ARMITSTEAD | {2011: 'Team Garmin - Cervelo', 2012: 'AA Drink - Leontien.nl', 2013: 'Boels:Dolmans Cycling Team', 2014: 'Boels:Dolmans Cycling Team', 2015: 'Boels:Dolmans Cycling Team'}
|
||||
5b6962dd-3f90-4c93-8f61-eabfa4a803e2 | Marianne | VOS | {2015: 'Rabobank-Liv Woman Cycling Team'}
|
||||
|
||||
(2 rows)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Connected to Test Cluster at cassandra:9042.
|
||||
[cqlsh 5.0.1 | Cassandra 4.0.4 | CQL spec 3.4.5 | Native protocol v5]
|
||||
Use HELP for help.
|
||||
cqlsh>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
// tag::cyclistSemiProDescribeResults[]
|
||||
CREATE TABLE cycling.cyclist_semi_pro (
|
||||
id int PRIMARY KEY,
|
||||
affiliation text,
|
||||
age int,
|
||||
country text,
|
||||
firstname text,
|
||||
lastname text,
|
||||
registration date
|
||||
) WITH additional_write_policy = '99PERCENTILE'
|
||||
AND bloom_filter_fp_chance = 0.01
|
||||
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
|
||||
AND comment = ''
|
||||
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
|
||||
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
|
||||
AND crc_check_chance = 1.0
|
||||
AND default_time_to_live = 0
|
||||
AND gc_grace_seconds = 864000
|
||||
AND max_index_interval = 2048
|
||||
AND memtable_flush_period_in_ms = 0
|
||||
AND min_index_interval = 128
|
||||
AND nodesync = {'enabled': 'true', 'incremental': 'true'}
|
||||
AND read_repair = 'BLOCKING'
|
||||
AND speculative_retry = '99PERCENTILE';
|
||||
CREATE CUSTOM INDEX registration_sai_idx ON cycling.cyclist_semi_pro (registration) USING 'StorageAttachedIndex';
|
||||
CREATE CUSTOM INDEX country_sai_idx ON cycling.cyclist_semi_pro (country) USING 'StorageAttachedIndex' WITH OPTIONS = {'normalize': 'true', 'case_sensitive': 'false', 'ascii': 'true'};
|
||||
CREATE CUSTOM INDEX age_sai_idx ON cycling.cyclist_semi_pro (age) USING 'StorageAttachedIndex';
|
||||
CREATE CUSTOM INDEX lastname_sai_idx ON cycling.cyclist_semi_pro (lastname) USING 'StorageAttachedIndex' WITH OPTIONS = {'normalize': 'true', 'case_sensitive': 'false', 'ascii': 'true'};
|
||||
// end::cyclistSemiProDescribeResults[]
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// SELECT * FROM cycling.cyclist_semi_pro WHERE age <= 23;
|
||||
|
||||
// tag::cyclistSelectAgeResults[]
|
||||
id | affiliation | age | country | firstname | lastname | registration
|
||||
----+--------------------+-----+---------+-----------+----------+--------------
|
||||
10 | Chamonix Hauteurs | 22 | FRA | Agnes | Cavani | 2020-01-02
|
||||
11 | Chamonix Hauteurs | 19 | FRA | Pablo | Verratti | 2006-05-15
|
||||
1 | Recco Club | 22 | ITA | Carlos | Perotti | 2020-01-12
|
||||
8 | Nice Cavaliers | 19 | FRA | Theo | Bernat | 2007-05-15
|
||||
2 | Venezia Velocità | 19 | ITA | Giovani | Pasi | 2016-05-15
|
||||
4 | Portofino Ciclisti | 19 | ITA | Mark | Pastore | 2017-06-16
|
||||
20 | London Cyclists | 18 | GBR | Leslie | Boyd | 2012-12-15
|
||||
7 | Paris Cyclistes | 21 | FRA | Marcel | Silva | 2018-04-28
|
||||
6 | Bellagio Ciclisti | 23 | ITA | Hugo | Herrera | 2004-02-12
|
||||
|
||||
(9 rows)
|
||||
// end::cyclistSelectAgeResults[]
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// SELECT * FROM cycling.cyclist_semi_pro WHERE country = 'GBR';
|
||||
|
||||
// tag::cyclistSelectCountryResults[]
|
||||
id | affiliation | age | country | firstname | lastname | registration
|
||||
----+----------------------+-----+---------+-----------+-----------+--------------
|
||||
19 | Highclere Agents | 24 | GBR | Tyler | Higgins | 2019-07-31
|
||||
18 | Aberdeen Association | 26 | GBR | Nicholas | Burrow | 2016-02-12
|
||||
20 | London Cyclists | 18 | GBR | Leslie | Boyd | 2012-12-15
|
||||
17 | Pennan Power | 26 | GBR | Alice | McCaffrey | 2020-02-12
|
||||
|
||||
(4 rows)
|
||||
// end::cyclistSelectCountryResults[]
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// SELECT * FROM cycling.cyclist_semi_pro WHERE registration > '2010-01-01' AND registration < '2015-12-31' LIMIT 10;
|
||||
|
||||
|
||||
// tag::cyclistSelectDateRangeResults[]
|
||||
id | affiliation | age | country | firstname | lastname | registration
|
||||
----+---------------------+-----+---------+-----------+----------+--------------
|
||||
5 | Como Velocità | 24 | ITA | Irene | Cantona | 2012-07-22
|
||||
16 | CU Alums Crankworkz | 28 | USA | Jenny | Hamler | 2012-07-22
|
||||
15 | Exeter Academy | 27 | USA | Thomas | Fulton | 2012-12-15
|
||||
20 | London Cyclists | 18 | GBR | Leslie | Boyd | 2012-12-15
|
||||
9 | Normandy Club | 24 | FRA | Richie | Draxler | 2011-02-26
|
||||
|
||||
(5 rows)
|
||||
// end::cyclistSelectDateRangeResults[]
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
SOURCE '0_create_keyspace.cql';
|
||||
|
||||
// SELECT * FROM cycling.cyclist_semi_pro WHERE lastname = 'Eppinger';
|
||||
|
||||
// tag::cyclistSelectSpecificRiderResults[]
|
||||
id | affiliation | age | country | firstname | lastname | registration
|
||||
----+-------------------+-----+---------+-----------+----------+--------------
|
||||
12 | Chamonix Hauteurs | 24 | FRA | Charles | Eppinger | 2018-07-29
|
||||
|
||||
(1 rows)
|
||||
// end::cyclistSelectSpecificRiderResults[]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
id | firstname | lastname | teams
|
||||
--------------------------------------+-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
cb07baad-eac8-4f65-b28a-bddc06a0de23 | Elizabeth | ARMITSTEAD | {2011: 'Team Garmin - Cervelo', 2012: 'AA Drink - Leontien.nl', 2013: 'Boels:Dolmans Cycling Team', 2014: 'Boels:Dolmans Cycling Team', 2015: 'Boels:Dolmans Cycling Team'}
|
||||
5b6962dd-3f90-4c93-8f61-eabfa4a803e2 | Marianne | VOS | {2015: 'Rabobank-Liv Woman Cycling Team'}
|
||||
|
||||
(2 rows)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
id | created_at | comment | comment_vector | commenter | record_id
|
||||
----+------------+---------+----------------+-----------+-----------
|
||||
|
||||
(0 rows)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
comment | commenter
|
||||
----------------------------------------+-----------
|
||||
LATE RIDERS SHOULD NOT DELAY THE START | Alex
|
||||
Second rest stop was out of water | Alex
|
||||
(2 rows)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
race_year | race_name | rank | cyclist_name
|
||||
-----------+--------------------------------------------+------+----------------------
|
||||
2014 | Tour of Japan - Stage 4 - Minami > Shinshu | 1 | Daniel MARTIN
|
||||
2014 | Tour of Japan - Stage 4 - Minami > Shinshu | 2 | Johan Esteban CHAVES
|
||||
2014 | Tour of Japan - Stage 4 - Minami > Shinshu | 3 | Benjamin PRADES
|
||||
2015 | Tour of Japan - Stage 4 - Minami > Shinshu | 1 | Benjamin PRADES
|
||||
2015 | Tour of Japan - Stage 4 - Minami > Shinshu | 2 | Adam PHELAN
|
||||
2015 | Tour of Japan - Stage 4 - Minami > Shinshu | 3 | Thomas LEBAS
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
race_year | race_name | rank | cyclist_name
|
||||
-----------+--------------------------------------------+------+----------------------
|
||||
2014 | 4th Tour of Beijing | 1 | Phillippe GILBERT
|
||||
2014 | 4th Tour of Beijing | 2 | Daniel MARTIN
|
||||
2014 | 4th Tour of Beijing | 3 | Johan Esteban CHAVES
|
||||
2014 | Tour of Japan - Stage 4 - Minami > Shinshu | 1 | Daniel MARTIN
|
||||
2014 | Tour of Japan - Stage 4 - Minami > Shinshu | 2 | Johan Esteban CHAVES
|
||||
2014 | Tour of Japan - Stage 4 - Minami > Shinshu | 3 | Benjamin PRADES
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
year | month | events
|
||||
------+-------+-----------------------------------------------
|
||||
2015 | 6 | ['Criterium du Dauphine', 'Tour de Sui\nsse']
|
||||
2015 | 7 | ['Tour de France']
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
year | month | events
|
||||
------+-------+-----------------------------------------------
|
||||
2015 | 6 | ['Criterium du Dauphine', 'Tour de Sui\nsse']
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
id | firstname | lastname | teams
|
||||
--------------------------------------+-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
cb07baad-eac8-4f65-b28a-bddc06a0de23 | Elizabeth | ARMITSTEAD | {2011: 'Team Garmin - Cervelo', 2012: 'AA Drink - Leontien.nl', 2013: 'Boels:Dolmans Cycling Team', 2014: 'Boels:Dolmans Cycling Team', 2015: 'Boels:Dolmans Cycling Team'}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
id | firstname | lastname | teams
|
||||
--------------------------------------+-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
cb07baad-eac8-4f65-b28a-bddc06a0de23 | Elizabeth | ARMITSTEAD | {2011: 'Team Garmin - Cervelo', 2012: 'AA Drink - Leontien.nl', 2013: 'Boels:Dolmans Cycling Team', 2014: 'Boels:Dolmans Cycling Team', 2015: 'Boels:Dolmans Cycling Team'}
|
||||
5b6962dd-3f90-4c93-8f61-eabfa4a803e2 | Marianne | VOS | {2014: 'Rabobank-Liv Woman Cycling Team', 2015: 'Rabobank-Liv Woman Cycling Team'}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
id | firstname | lastname | teams
|
||||
--------------------------------------+-----------+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
cb07baad-eac8-4f65-b28a-bddc06a0de23 | Elizabeth | ARMITSTEAD | {2011: 'Team Garmin - Cervelo', 2012: 'AA Drink - Leontien.nl', 2013: 'Boels:Dolmans Cycling Team', 2014: 'Boels:Dolmans Cycling Team', 2015: 'Boels:Dolmans Cycling Team'}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
id | lastname | teams
|
||||
--------------------------------------+----------+------------------------------------------------------------------------------------------------------
|
||||
5b6962dd-3f90-4c93-8f61-eabfa4a803e2 | VOS | {'Nederland bloeit', 'Rabobank Women Team', 'Rabobank-Liv Giant', 'Rabobank-Liv Woman Cycling Team'}
|
||||