Skip to content

Conversation

@Akzestia
Copy link

Introduced separate grammar for CQL.

  • I am adding a new language.
    • The extension of the new language is used in hundreds of repositories on GitHub.com.
    • I have included a real-world usage sample for all extensions added in this PR:
    • I have included a syntax highlighting grammar: cqlTextMate (Also see examples below SQL vs CQL)
    • I have added a color
      • Hex value: #006091
      • Based on Apache Cassandra color scheme(Open to any suggestions regarding more fitting color).

Example highlights:

Screenshots are from VS Code with TextMate languages extension

ALTER MATERIALIZED VIEW cycling.cyclist_by_age
WITH comment = 'A most excellent and useful view'
AND bloom_filter_fp_chance = 0.02;

ALTER MATERIALIZED VIEW cycling.cyclist_by_age
WITH compression = {
    'sstable_compression' : 'DeflateCompressor',
    'chunk_length_kb' : 64
}
AND compaction = {
    'class' : 'SizeTieredCompactionStrategy',
    'max_threshold' : 64
};

ALTER MATERIALIZED VIEW cycling.cyclist_by_age
WITH caching = {
    'keys' : 'NONE',
    'rows_per_partition' : '15'
};
{A74DDF5D-BB17-48D5-9C84-CD3AD7723F6B}
ALTER ROLE sandy WITH PASSWORD = 'bestTeam';

ALTER ROLE sandy WITH SUPERUSER=true;

ALTER ROLE team_manager WITH LOGIN=true;
{3B8D2DCF-DE3B-4C6E-BFCB-646BEE91F23A}
ALTER TABLE cycling.cyclist_races
ADD manager UUID;

ALTER TABLE cycling.cyclist_races
ADD completed list<text>;

ALTER TABLE cycling.cyclist_races;

DROP manager;

ALTER TABLE cycling.race_times RENAME race_date TO date;

ALTER TABLE food_cql_conversion.person WITH VERTEX LABEL "person";

ALTER TABLE food_cql_conversion.person_authored_book
WITH EDGE LABEL "authored"
FROM person(person_name, person_id)
TO book(book_name, book_id);

ALTER TABLE food.person RENAME VERTEX LABEL TO "personX";

ALTER TABLE food."person_authored_book" RENAME EDGE LABEL TO "authoredX";

ALTER TABLE food.person WITHOUT VERTEX LABEL "personX";

ALTER TABLE food."person_authored_book" WITHOUT EDGE LABEL "authoredX";

ALTER TABLE cycling.cyclist_base
WITH comment = 'basic cyclist information';

ALTER TABLE cycling.comments WITH caching = {
    'keys' : 'NONE',
    'rows_per_partition' : 10
};

ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '95percentile';

ALTER TABLE cycling.cyclist_base
WITH speculative_retry = '10ms';

ALTER TABLE cycling.comments WITH COMPACTION = {
    'class' : 'SizeTieredCompactionStrategy',
    'enabled' : 'false'
};
{A62F230D-811B-4A40-8629-F08FE56F1478}
ALTER TYPE cycling.fullname
ADD middlename text;

ALTER TYPE cycling.fullname
RENAME middlename TO middle
AND lastname TO last
AND firstname TO first;
{3AEBAC40-BC24-4EA4-85C2-353AAC5FAFF2}
// @xx
-- @xx
/*
    This is the first line of
    of a comment that spans multiple
    lines
*/
CREATE ROLE IF NOT EXISTS coach -- End of line comment
WITH LOGIN = true
AND PASSWORD = 'All4One2day!';

CREATE ROLE IF NOT EXISTS sys_admin // End of line comment
WITH LOGIN = true
AND PASSWORD = 'changeme'
AND SUPERUSER = true;

/* @name some block */
{6AD4CB6B-56A6-4468-A634-560AAF568680}
CREATE KEYSPACE IF NOT EXISTS cycling
WITH REPLICATION = {
    'class' : 'SimpleStrategy',
    'replication_factor' : 1
};

CREATE KEYSPACE food_cql
WITH REPLICATION = {
    'class': 'SimpleStrategy',
    'replication_factor': 1
}
AND graph_engine = 'Core';

CREATE KEYSPACE cycling
WITH REPLICATION = {
    'class' : 'NetworkTopologyStrategy',
    'dc1' : 1
};

CREATE KEYSPACE IF NOT EXISTS cycling
WITH REPLICATION = {
    'class' : 'NetworkTopologyStrategy',
    'datacenter1': '3',
    'datacenter2': '3'
};

CREATE KEYSPACE cycling
WITH REPLICATION = {
    'class' : 'NetworkTopologyStrategy',
    'datacenter1' : 3
}
AND DURABLE_WRITES = false;
{F56EBC0D-6BEA-4C97-BC89-9D4583C4FF4A}
CREATE KEYSPACE videod
WITH REPLICATION = {
    'class' : 'SimpleStrategy',
    'replication_factor' : 1
};

use videodb;

// Basic entity table
// Object mapping ?
CREATE TABLE users (
    username                  varchar,
    firstname                 varchar,
    lastname                  varchar,
    email                     varchar,
    password                  varchar,
    created_date              timestamp,
    total_credits             int,
    credit_change_date        timeuuid,

    PRIMARY KEY (username)
);

// One-to-many entity table
CREATE TABLE videos (
    videoid            uuid,
    videoname          varchar,
    username           varchar,
    description        varchar,
    tags               list<varchar>,
    upload_date        timestamp,

    PRIMARY KEY (videoid)
);

// One-to-many from the user point of view
// Also know as a lookup table
CREATE TABLE username_video_index (
    username           varchar,
    videoid            uuid,
    upload_date        timestamp,
    videoname          varchar,

    PRIMARY KEY (username, videoid)
);

// Counter table
CREATE TABLE video_rating (
    videoid               uuid,
    rating_counter        counter,
    rating_total          counter,

    PRIMARY KEY (videoid)
);

// Creating index tables for tab keywords
CREATE TABLE tag_index (
    tag            varchar,
    videoid        uuid,
    timestamp      timestamp,

    PRIMARY KEY (tag, videoid)
);

// Comments as a many-to-many
// Looking from the video side to many users
CREATE TABLE comments_by_video (
    videoid           uuid,
    username          varchar,
    comment_ts        timestamp,
    comment           varchar,

    PRIMARY KEY (videoid, comment_ts, username)
) WITH CLUSTERING ORDER BY (comment_ts DESC, username ASC);

// looking from the user side to many videos
CREATE TABLE comments_by_user (
    username          varchar,
    videoid           uuid,
    comment_ts        timestamp,
    comment           varchar,

    PRIMARY KEY (username, comment_ts, videoid)
) WITH CLUSTERING ORDER BY (comment_ts DESC, videoid ASC);

// Time series wide row with reverse comparator
CREATE TABLE video_event (
    videoid                uuid,
    username               varchar,
    event                  varchar,
    event_timestamp        timeuuid,
    video_timestamp        bigint,

    PRIMARY KEY ((videoid, username), event_timestamp, event)
) WITH CLUSTERING ORDER BY (event_timestamp DESC, event ASC);
{8229944C-E2D1-4EFC-92FD-FCF032E4BDF2} {87A2AD10-FA68-4F70-B00C-9E36AC22FEDA}

@Akzestia Akzestia requested a review from a team as a code owner December 27, 2025 19:03
@Akzestia Akzestia changed the title Add Support for CQL Add Separate Grammar for CQL (Cassandra Query Language) Dec 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant