blerer commented on code in PR #3831: URL: https://github.com/apache/cassandra/pull/3831#discussion_r1936831243
########## src/java/org/apache/cassandra/cql3/statements/schema/CopyTableStatement.java: ########## @@ -227,13 +237,50 @@ public void validate(ClientState state) Guardrails.tables.guard(totalUserTables + 1, targetTableName, false, state); } validateDefaultTimeToLive(attrs.asNewTableParams()); + + if (createLikeOptions.contains(ALL) && createLikeOptions.size() > 1) + { + throw ire("It is not allowed to use ALL option together with " + createLikeOptions.stream().filter(option -> option != ALL).sorted().collect(Collectors.toList())); + } + } + + private void cloneIndexesAndTriggersIfNeeded(TableMetadata.Builder builder, TableMetadata sourceTableMeta, KeyspaceMetadata targetKeyspaceMeta, String targetTableName) + { + if (createLikeOptions.contains(INDEX) || + createLikeOptions.contains(ALL)) + { + Indexes.Builder idxBuilder = Indexes.builder(); + for (IndexMetadata indexMetadata : sourceTableMeta.indexes) + { + // todo use source index name if target keyspace don't have same index name but use random name now as cep-43 described + String baseName = targetKeyspaceMeta.name + "_" + targetTableName + "_" + indexMetadata.name; + String idxName = targetKeyspaceMeta.findAvailableIndexName(baseName); + idxBuilder.add(IndexMetadata.fromSchemaMetadata(idxName, indexMetadata.kind, indexMetadata.options)); Review Comment: I am a bit confused by the logic surrounding the index and trigger name. I fear that it will bring more confusion than anything else. If an index with the same name already exists we should probably raise an error and let the user deal with it, no? -- 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