blerer commented on a change in pull request #883:
URL: https://github.com/apache/cassandra/pull/883#discussion_r567829322



##########
File path: 
test/unit/org/apache/cassandra/cql3/validation/operations/CreateTest.java
##########
@@ -688,12 +692,16 @@ public void testCreateTableWithCompression() throws 
Throwable
     @Test
     public void testUseUnreservedKeywordAsColumnName()
     {
-        List<String> names = Arrays.asList("access", "datacenters");
-        for (String colName : names)
+        Set<String> allKeywords = 
Arrays.stream(CqlLexer.class.getDeclaredFields())
+                                        .filter(f -> 
f.getName().startsWith("K_"))
+                                        .map(f -> f.getName().substring(2)) // 
remove the heading "K_"
+                                        .collect(Collectors.toSet());
+        Set<String> unreservedKeywords = Sets.difference(allKeywords, 
ReservedKeywords.reservedSet);

Review comment:
       Another approach would be to make `isReserved(String text)` `public` and 
to use it to filter the stream.
   ```
   
   Set<String> unreservedKeywords = 
Arrays.stream(CqlLexer.class.getDeclaredFields())
                                                                     .filter(f 
-> f.getName().startsWith("K_"))
                                                                     .map(f -> 
f.getName().substring(2)) // remove the heading "K_"
                                                                     .filter(f 
-> !ReservedKeywords.isReserved(f))
                                                                    
.collect(Collectors.toSet());
   ```
   Making `isReserved(String text)` `public` allow us to expose less of the 
class internals but I do not really have a strong opinion on which solution we 
should use.

##########
File path: src/java/org/apache/cassandra/cql3/ReservedKeywords.java
##########
@@ -23,7 +23,7 @@
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableSet;
 
-class ReservedKeywords
+public class ReservedKeywords

Review comment:
       We should probably make the class `final`.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to