Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASANDRA-15663 (3.11) DESCRIBE KEYSPACE does not properly quote table names #1105

Closed
wants to merge 6 commits into from

Conversation

adelapena
Copy link
Contributor

No description provided.

Comment on lines 26 to 57
cql_keywords = set((
'add', 'aggregate', 'all', 'allow', 'alter', 'and', 'apply', 'as', 'asc', 'ascii', 'authorize', 'batch', 'begin',
'bigint', 'blob', 'boolean', 'by', 'called', 'cast', 'clustering', 'columnfamily', 'compact', 'contains', 'count',
'counter', 'create', 'custom', 'date', 'decimal', 'default', 'delete', 'desc', 'describe', 'distinct', 'double',
'drop', 'duration', 'entries', 'execute', 'exists', 'filtering', 'finalfunc', 'float', 'from', 'frozen', 'full',
'function', 'functions', 'grant', 'group', 'if', 'in', 'index', 'inet', 'infinity', 'initcond', 'input', 'insert',
'int', 'into', 'is', 'json', 'key', 'keys', 'keyspace', 'keyspaces', 'language', 'like', 'limit', 'list', 'login',
'map', 'materialized', 'mbean', 'mbeans', 'modify', 'nan', 'nologin', 'norecursive', 'nosuperuser', 'not', 'null',
'of', 'on', 'options', 'or', 'order', 'partition', 'password', 'per', 'permission', 'permissions', 'primary',
'rename', 'replace', 'returns', 'revoke', 'role', 'roles', 'schema', 'select', 'set', 'sfunc', 'smallint', 'static',
'storage', 'stype', 'superuser', 'table', 'text', 'time', 'timestamp', 'timeuuid', 'tinyint', 'to', 'token',
'trigger', 'truncate', 'ttl', 'tuple', 'type', 'unlogged', 'unset', 'update', 'use', 'user', 'users', 'using',
'uuid', 'values', 'varchar', 'varint', 'view', 'where', 'with', 'writetime'
))
"""
Set of keywords in CQL.

Derived from .../cassandra/src/java/org/apache/cassandra/cql3/Lexer.g
"""

cql_keywords_unreserved = set((
'aggregate', 'all', 'as', 'called', 'clustering', 'compact', 'contains', 'custom', 'exists', 'filtering',
'finalfunc', 'frozen', 'function', 'functions', 'group', 'initcond', 'input', 'keys', 'keyspaces', 'language',
'like', 'list', 'login', 'map', 'nologin', 'nosuperuser', 'options', 'partition', 'password', 'per', 'permission',
'permissions', 'returns', 'role', 'roles', 'sfunc', 'static', 'storage', 'stype', 'superuser', 'trigger', 'tuple',
'type', 'user', 'users', 'values'
))
"""
Set of unreserved keywords in CQL.

Derived from .../cassandra/src/java/org/apache/cassandra/cql3/Parser.g
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned on the Jira ticket, I think we only need to override cql_keywords_reserved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -56,7 +56,8 @@ lexer grammar Lexer;
}

// Case-insensitive keywords
// When adding a new reserved keyword, add entry to o.a.c.cql3.ReservedKeywords as well
// When adding a new reserved keyword, add entry to o.a.c.cql3.ReservedKeywords and
// pylib/cqlshlib/cqlhandling.py::CqlParsingRuleSet.cql_keywords_reserved as well
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I think it's pylib/cqlshlib/cqlhandling.py::cql_keywords_reserved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private static final Set<String> reservedSet = ImmutableSet.copyOf(reservedKeywords);
private static final String FILE_NAME = "reserved_keywords.txt";

static final Set<String> reservedKeywords = getFromResource();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we have missed the @VisibleForTestingannotation for reservedKeywords

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adelapena adelapena closed this Nov 10, 2021
pcmanus pushed a commit to pcmanus/cassandra that referenced this pull request May 21, 2024
CNDB-9357: merge ds-trunk to vsearch
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.

3 participants