Skip to content

Commit 943c943

Browse files
adelapenadjatnieks
authored andcommitted
CNDB-12733: Make ANN a separate, unreserved keyword (#1546)
Make ANN a separate, unreserved keyword, instead of using `ANN OF` as a single keyword, so we can create a table named `ann` without using quotes.
1 parent 67662ec commit 943c943

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/antlr/Lexer.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ K_LABEL: L A B E L;
236236
K_DROPPED: D R O P P E D;
237237
K_COLUMN: C O L U M N;
238238
K_RECORD: R E C O R D;
239-
K_ANN_OF: A N N WS+ O F;
239+
K_ANN: A N N;
240240

241241
// Case-insensitive alpha characters
242242
fragment A: ('a'|'A');

src/antlr/Parser.g

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ orderByClause[List<Ordering.Raw> orderings]
465465
@init{
466466
Ordering.Direction direction = Ordering.Direction.ASC;
467467
}
468-
: c=cident (K_ANN_OF t=term)? (K_ASC | K_DESC { direction = Ordering.Direction.DESC; })?
468+
: c=cident (K_ANN K_OF t=term)? (K_ASC | K_DESC { direction = Ordering.Direction.DESC; })?
469469
{
470470
Ordering.Raw.Expression expr = (t == null)
471471
? new Ordering.Raw.SingleColumn(c)
@@ -2087,7 +2087,7 @@ basic_unreserved_keyword returns [String str]
20872087
| K_DROPPED
20882088
| K_COLUMN
20892089
| K_RECORD
2090-
| K_ANN_OF
2090+
| K_ANN
20912091
| K_OFFSET
20922092
| K_DETERMINISTIC
20932093
| K_MONOTONIC

test/unit/org/apache/cassandra/cql3/KeywordTestBase.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232

3333
import org.apache.cassandra.exceptions.SyntaxException;
3434
import org.apache.cassandra.service.StorageService;
35+
import org.assertj.core.api.Assertions;
3536

3637
/**
3738
* This class tests all keywords which took a long time. Hence it was split into multiple
@@ -47,6 +48,12 @@ public abstract class KeywordTestBase extends CQLTester
4748
})
4849
.collect(Collectors.toList());
4950

51+
static
52+
{
53+
// ensure that ANN is a separate keyword, so it's included on this tests (see CNDB-12733)
54+
Assertions.assertThat(keywords).contains(new Object[]{"ANN", false});
55+
}
56+
5057
public static Collection<Object[]> getKeywordsForSplit(int split, int totalSplits)
5158
{
5259
return Sets.newHashSet(Lists.partition(KeywordTestBase.keywords, KeywordTestBase.keywords.size() / totalSplits)

0 commit comments

Comments
 (0)