table-cyclist-base

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (e7ae5cf3-d358-4d99-b900-85902fda9bb0,'Alex FRAME', 22, '1993-06-18',
  'New Zealand');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (220844bf-4860-49d6-9a4b-6b5d3a79cbfb,'Paolo TIRALONGO', 38,
'1977-07-08', 'Italy');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (6ab09bec-e68e-48d9-a5f8-97e6fb4c9b47,'Steven KRUIKSWIJK', 28,
'1987-06-07', 'Netherlands');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (ffdfa2a7-5fc6-49a7-bfdc-3fcdcfdd7156,'Pascal EENKHOORN', 18,
'1997-02-08', 'Netherlands');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (18f471bf-f631-4bc4-a9a2-d6f6cf5ea503,'Bram WELTEN', 18,
'1997-03-29', 'Netherlands');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (95fed1a4-db7e-4c8d-8b2d-f7f9340f2c0b,'Zam WEATON', 20,
'1993-04-09', 'United States');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (15a116fc-b833-4da6-ab9a-4a7775752836,'Adrien COSTA', 18,
'1997-08-19', 'United States');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (862cc51f-00a1-4d5a-976b-a359cab7300e,'Joakim BUKDAL', 20,
'1994-09-04', 'Denmark');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (c9c9c484-5e4a-4542-8203-8d047a01b8a8,'Cristian EGIDIO', 27,
'1987-09-04', 'Brazil');

INSERT INTO cycling.cyclist_base (cid,name,age,birthday,country)
VALUES (1c526849-d3a2-42a3-bcf9-7903c80b3d16,'Kanden GROVES',19,
'1998-12-23','Australia');
CREATE CUSTOM INDEX IF NOT EXISTS age_sasi_idx ON cycling.cyclist_base (age)
  USING 'org.apache.cassandra.index.sasi.SASIIndex'
  WITH OPTIONS = {
    'mode': 'PREFIX'
  };
CREATE CUSTOM INDEX bio_text_analysis_idx ON cycling.cyclist_base (bio)
  USING 'org.apache.cassandra.index.sasi.SASIIndex'
  WITH OPTIONS = {
    'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.StandardAnalyzer',
    'tokenization_enable_stemming': 'true',
    'analyzed': 'true',
    'tokenization_normalize_lowercase': 'true',
    'tokenization_locale': 'en'
  };
CREATE CUSTOM INDEX IF NOT EXISTS birthday_sasi_idx ON cycling.cyclist_base (birthday)
  USING 'org.apache.cassandra.index.sasi.SASIIndex'
  WITH OPTIONS = {
    'mode': 'SPARSE'
  };
CREATE CUSTOM INDEX IF NOT EXISTS id_sasi_idx
  ON cycling.cyclist_base (id)
  USING 'org.apache.cassandra.index.sasi.SASIIndex';
CREATE CUSTOM INDEX IF NOT EXISTS name_sasi_idx
  ON cycling.cyclist_base (name)
  USING 'org.apache.cassandra.index.sasi.SASIIndex'
  WITH OPTIONS = {
    'mode': 'CONTAINS'
  };
CREATE CUSTOM INDEX IF NOT EXISTS name_sasi_idx
  ON cycling.cyclist_base (name)
  USING 'org.apache.cassandra.index.sasi.SASIIndex'
  WITH OPTIONS = {
    'mode': 'CONTAINS',
    'case_sensitive': 'false'
  };
CREATE CUSTOM INDEX IF NOT EXISTS name_sasi_idx
  ON cycling.cyclist_base (name)
  USING 'org.apache.cassandra.index.sasi.SASIIndex';
CREATE CUSTOM INDEX IF NOT EXISTS name_sasi_idx
  ON cycling.cyclist_base (name)
  USING 'org.apache.cassandra.index.sasi.SASIIndex'
  WITH OPTIONS = {
    'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.NonTokenizingAnalyzer',
    'case_sensitive': 'false'
  };
CREATE CUSTOM INDEX delimiter_sasi_idx on cycling.cyclist_base (aliases)
  USING 'org.apache.cassandra.index.sasi.SASIIndex'
  WITH OPTIONS = {
    'analyzer_class': 'org.apache.cassandra.index.sasi.analyzer.DelimiterAnalyzer',
    'delimiter': ',',
    'mode': 'prefix',
    'analyzed': 'true'
  };
DESCRIBE INDEX cycling.age_sasi_idx;
DESCRIBE INDEX cycling.bio_text_analysis_sasi_idx;
DESCRIBE INDEX cycling.birthday_sasi_idx;
DESCRIBE INDEX cycling.delimiter_sasi_idx;
DESCRIBE INDEX cycling.name_sasi_idx;
DESCRIBE INDEX cycling.name_sasi_idx;
DESCRIBE INDEX cycling.name_sasi_idx;
DESCRIBE INDEX cycling.name_sasi_idx;
DROP INDEX IF EXISTS cycling.id_sasi_idx;
DROP INDEX IF EXISTS cycling.name_sasi_idx;
SELECT * FROM cycling.cyclist_base WHERE age >= 28 AND age < 20;
SELECT * FROM cycling.cyclist_base WHERE age = 20;
SELECT * FROM cycling.cyclist_base WHERE age >= 20;
SELECT * FROM cycling.cyclist_base WHERE aliases LIKE 'Stevie' ALLOW FILTERING;
SELECT * FROM cycling.cyclist_base;
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'winning';
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'like';
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'races';
SELECT * FROM cycling.cyclist_base WHERE birthday = '1987-06-07';
SELECT * FROM cycling.cyclist_base WHERE birthday >= '1997-03-29';
SELECT * FROM cycling.cyclist_base WHERE name LIKE 'A%' AND age > 20
  ALLOW FILTERING;
SELECT * FROM cyclist_base WHERE name LIKE '%A' AND birthday > '1987-09-04'
  ALLOW FILTERING;
SELECT * FROM cycling.cyclist_base WHERE name LIKE '%am WE%';
SELECT * FROM cycling.cyclist_base WHERE name LIKE '%am we%';
SELECT * FROM cycling.cyclist_base WHERE name = 'Joakim BUKDAL';
SELECT * FROM cycling.cyclist_base WHERE name LIKE 'A%';
SELECT * FROM cycling.cyclist_base WHERE name LIKE 'a%';
SELECT * FROM cycling.cyclist_base WHERE name LIKE '%go';
SELECT * FROM cycling.cyclist_base WHERE name LIKE '%GO';
ALTER TABLE cycling.cyclist_base
  ADD aliases set<text>;
ALTER TABLE cycling.cyclist_base ADD bio text;
ALTER TABLE cycling.cyclist_base
  WITH comment = 'basic cyclist information';
ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '95percentile';
ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '10ms';
CREATE TABLE IF NOT EXISTS cycling.cyclist_base (
  cid UUID PRIMARY KEY,
  name text,
  age int,
  birthday date,
  country text
);
DESCRIBE TABLE cycling.cyclist_base;
DESCRIBE TABLE cycling.cyclist_base;
DROP TABLE IF EXISTS cycling.cyclist_base;
UPDATE cycling.cyclist_base SET aliases = 'Steve,Steven,Stevie'
  WHERE cid = 6ab09bec-e68e-48d9-a5f8-97e6fb4c9b47;
// end::data-update-aliases[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Updated aliases"

# LLP: WHY DOES THIS HAVE ALLOW FILTERING?
# Query aliases delimiter SASI
tag="select-aliases-delimiter-sasi[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::select-aliases-delimiter-sasi[]
SELECT * FROM cycling.cyclist_base WHERE aliases LIKE 'Stevie' ALLOW FILTERING;
// end::select-aliases-delimiter-sasi[]
//" >> $results_table
echo "// end::$tag" >> $results_table
echo "Select aliases delimiter SASI"

tag="table-alter-with-bio[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-alter-with-bio[]
ALTER TABLE cycling.cyclist_base ADD bio text;
// end::table-alter-with-bio[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Altered table with bio added"

tag="table-update-bio[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-update-bio[]
UPDATE cycling.cyclist_base
  SET bio = 'Professional cyclist, who likes racing in Asia and Europe, wins a lot.'
  WHERE cid = 15a116fc-b833-4da6-ab9a-4a7775752836;
UPDATE cycling.cyclist_base
  SET bio = 'Semi-pro cyclist, works delivering packages at night and winning races.'
  WHERE cid = 95fed1a4-db7e-4c8d-8b2d-f7f9340f2c0b;
// end::data-update-bio[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Updated bio"

# Query bio stemming SASI
tag="select-bio-stemming-sasi[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::select-bio-stemming-sasi[]
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'winning';
// end::select-bio-stemming-sasi[]
//" >> $results_table
echo "// end::$tag" >> $results_table
echo "Select bio stemming SASI"

# Query bio stemming SASI 2
tag="select-bio-stemming-sasi-2[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::select-bio-stemming-sasi-2[]
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'like';
// end::select-bio-stemming-sasi-2[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Select bio stemming SASI 2"

# Query bio stemming SASI 3
tag="select-bio-stemming-sasi-3[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::select-bio-stemming-sasi-3[]
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'races';
// end::select-bio-stemming-sasi-3[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Select bio stemming SASI 3"

# Alter table with comment
tag="table-alter-with-comment[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-alter-with-comment[]
ALTER TABLE cycling.cyclist_base
  WITH comment = 'basic cyclist information';
// end::table-alter-with-comment[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Altered table with comment"

# Alter table with speculative retry
tag="table-alter-with-speculative-retry[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-alter-with-speculative-retry[]
ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '95percentile';
// end::table-alter-with-speculative-retry[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Altered table with speculative retry"

# Alter table with speculative retry microseconds
tag="table-alter-with-speculative-retry-microseconds[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-alter-with-speculative-retry-microseconds[]
ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '10ms';
// end::table-alter-with-speculative-retry-microseconds[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Altered table with speculative retry microseconds"

tag="table-describe-with-altered-values[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-describe-with-altered-values[]
DESCRIBE TABLE cycling.cyclist_base;
// end::table-describe-with-altered-values[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Described table with altered values"
UPDATE cycling.cyclist_base
  SET bio = 'Professional cyclist, who likes racing in Asia and Europe, wins a lot.'
  WHERE cid = 15a116fc-b833-4da6-ab9a-4a7775752836;
UPDATE cycling.cyclist_base
  SET bio = 'Semi-pro cyclist, works delivering packages at night and winning races.'
  WHERE cid = 95fed1a4-db7e-4c8d-8b2d-f7f9340f2c0b;
// end::data-update-bio[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Updated bio"

# Query bio stemming SASI
tag="select-bio-stemming-sasi[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::select-bio-stemming-sasi[]
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'winning';
// end::select-bio-stemming-sasi[]
//" >> $results_table
echo "// end::$tag" >> $results_table
echo "Select bio stemming SASI"

# Query bio stemming SASI 2
tag="select-bio-stemming-sasi-2[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::select-bio-stemming-sasi-2[]
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'like';
// end::select-bio-stemming-sasi-2[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Select bio stemming SASI 2"

# Query bio stemming SASI 3
tag="select-bio-stemming-sasi-3[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::select-bio-stemming-sasi-3[]
SELECT name, country, age, bio FROM cycling.cyclist_base
  WHERE bio LIKE 'races';
// end::select-bio-stemming-sasi-3[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Select bio stemming SASI 3"

# Alter table with comment
tag="table-alter-with-comment[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-alter-with-comment[]
ALTER TABLE cycling.cyclist_base
  WITH comment = 'basic cyclist information';
// end::table-alter-with-comment[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Altered table with comment"

# Alter table with speculative retry
tag="table-alter-with-speculative-retry[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-alter-with-speculative-retry[]
ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '95percentile';
// end::table-alter-with-speculative-retry[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Altered table with speculative retry"

# Alter table with speculative retry microseconds
tag="table-alter-with-speculative-retry-microseconds[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-alter-with-speculative-retry-microseconds[]
ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '10ms';
// end::table-alter-with-speculative-retry-microseconds[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Altered table with speculative retry microseconds"

tag="table-describe-with-altered-values[]"
echo -e "\n// tag::$tag" >> $results_table
$cqlsh -e "
// tag::table-describe-with-altered-values[]
DESCRIBE TABLE cycling.cyclist_base;
// end::table-describe-with-altered-values[]
" >> $results_table
echo "// end::$tag" >> $results_table
echo "Described table with altered values"

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, info@datastax.com