smiklosovic commented on code in PR #3831:
URL: https://github.com/apache/cassandra/pull/3831#discussion_r1939201295


##########
src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java:
##########
@@ -229,12 +234,37 @@ public void validate(ClientState state)
         validateDefaultTimeToLive(attrs.asNewTableParams());
     }
 
+    private void cloneIndexesIfNeeded(TableMetadata.Builder builder, 
TableMetadata sourceTableMeta, KeyspaceMetadata targetKeyspaceMeta)
+    {
+        if (createLikeOption == CreateLikeOption.INDEX)
+        {
+            Indexes.Builder idxBuilder = Indexes.builder();
+            for (IndexMetadata indexMetadata : sourceTableMeta.indexes)
+            {
+                if (indexMetadata.kind == IndexMetadata.Kind.CUSTOM)
+                    throw ire("CUSTOM INDEX is not supported.");

Review Comment:
   great! Maybe specifying keyspace, table and name of custom index in this 
message will be helpful for users.
   
   EDIT: The shortcoming of this is that, imagine we have three indexes, two 
indexes are e.g. legacy 2i (not sai) and the third index is custom.
   
   What you do here is that as soon as you encounter custom index, you will 
fail.
   
   Imagine that sourceTableMeta.indexes contains these indexes:
   
   1) first index 2i
   2) second index custom
   3) third index 2i
   
   Then you create first index and you fail on the second so you will not add 
the third.
   
   We have in general two options
   
   1) iterate over `sourceTableMeta.indexes` and check if there is some custom 
index and if it is, we fail
   2) iterate over `sourceTableMeta.indexes` and if there is a custom index, we 
will just skip it. That means that all non-custom indexes will be still 
created. 



##########
src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java:
##########
@@ -229,12 +234,37 @@ public void validate(ClientState state)
         validateDefaultTimeToLive(attrs.asNewTableParams());
     }
 
+    private void cloneIndexesIfNeeded(TableMetadata.Builder builder, 
TableMetadata sourceTableMeta, KeyspaceMetadata targetKeyspaceMeta)
+    {
+        if (createLikeOption == CreateLikeOption.INDEX)
+        {
+            Indexes.Builder idxBuilder = Indexes.builder();
+            for (IndexMetadata indexMetadata : sourceTableMeta.indexes)
+            {
+                if (indexMetadata.kind == IndexMetadata.Kind.CUSTOM)
+                    throw ire("CUSTOM INDEX is not supported.");

Review Comment:
   @Maxwell-Guo The shortcoming of this is that, imagine we have three indexes, 
two indexes are e.g. legacy 2i (not sai) and the third index is custom.
   
   What you do here is that as soon as you encounter custom index, you will 
fail.
   
   Imagine that sourceTableMeta.indexes contains these indexes:
   
   1) first index 2i
   2) second index custom
   3) third index 2i
   
   Then you create first index and you fail on the second so you will not add 
the third.
   
   We have in general two options
   
   1) iterate over `sourceTableMeta.indexes` and check if there is some custom 
index and if it is, we fail
   2) iterate over `sourceTableMeta.indexes` and if there is a custom index, we 
will just skip it. That means that all non-custom indexes will be still 
created. 



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

Reply via email to