absurdfarce commented on PR #2005: URL: https://github.com/apache/cassandra-java-driver/pull/2005#issuecomment-2831356569
So, there's definitely something weird going on here. In Apache Cassandra 5.x "ann" is [very definitely](https://github.com/apache/cassandra/blob/cassandra-5.0.4/src/antlr/Parser.g#L2023) an _unreserved_ keyword. The [CQL docs](https://github.com/apache/cassandra/blob/cassandra-5.0.4/doc/cql3/CQL.textile#appendix-a-cql-keywords) in the Cassandra repo talk about the distinction a bit; reserved keywords can never be used as an identifier while unreserved keywords _can_ in some situations... but those situations aren't specified. If an unreserved identifier is used in a spot that might introduce conflict it presumably would have to be quoted... but it's not clear how the driver can identify such a situation. The dsbulk change I referenced above doesn't need to worry about this distinction. It includes it's own ANTLR-derived parser (a subset of what's actually used in Cassandra) so it can identify these keyword cases using (essentially) the same grammar Apache Cassandra uses. I also note that the set "ann" is added to in this PR is explicitly for reserved keywords; note that each member of that set is a reserved keyword (as defined in the CQL docs above) and that no unreserved keywords are included. Presumably that's true because the code can _always_ quote reserved keywords when generating CQL strings... but unreserved keywords are a bit tricker. To make it even worse: I note the following against Apache Cassandra 5.0.0: ``` cqlsh> describe keyspace test; CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; cqlsh> CREATE TABLE test.filtering (i int PRIMARY KEY, j float); cqlsh> CREATE TABLE test.ann (i int PRIMARY KEY, j float); cqlsh> ``` The string "ann" works just fine as a table name there. But when I try something similar on Astra I get results similar to what I think you're describing: ``` token@cqlsh> CREATE TABLE janus.filtering (i int PRIMARY KEY, j float); token@cqlsh> CREATE TABLE janus.function (i int PRIMARY KEY, j float); token@cqlsh> CREATE TABLE janus.ann (i int PRIMARY KEY, j float); SyntaxException: line 1:23 mismatched character '(' expecting set null token@cqlsh> CREATE TABLE janus.”ann” (i int PRIMARY KEY, j float); Invalid syntax at char 20 CREATE TABLE janus.”ann” (i int PRIMARY KEY, j float); ^ token@cqlsh> CREATE TABLE janus.’ann’ (i int PRIMARY KEY, j float); Invalid syntax at char 20 CREATE TABLE janus.’ann’ (i int PRIMARY KEY, j float); ^ ``` So we've clearly got inconsistencies in the behaviour here between Astra and Apache Cassandra. But to make matters worse Astra is internally inconsistent: some unreserved keywords (such as "filtering" and "function") are just fine to use as table names while I can't get "ann" to be used as a table name whether I quote it or not. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org For additional commands, e-mail: pr-h...@cassandra.apache.org