This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git

commit 4f5cb2a6fa287ab2d388c636655d6e764c648084
Merge: 1d961679a0 1f6b37d189
Author: Brandon Williams <[email protected]>
AuthorDate: Wed Jun 14 11:36:02 2023 -0500

    Merge branch 'cassandra-4.1' into trunk

 CHANGES.txt                                        |  1 +
 .../statements/schema/CreateTableStatement.java    | 10 +++-
 .../schema/CreateTableValidationTest.java          | 59 ++++++++++++++++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)

diff --cc 
src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java
index 45f23e9bfc,3799178747..6e93929d78
--- 
a/src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java
+++ 
b/src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java
@@@ -18,9 -18,8 +18,10 @@@
  package org.apache.cassandra.cql3.statements.schema;
  
  import java.util.*;
+ import java.util.stream.Collectors;
  
 +import javax.annotation.Nullable;
 +
  import com.google.common.collect.ImmutableSet;
  
  import org.apache.commons.lang3.StringUtils;
@@@ -255,13 -244,18 +256,18 @@@ public final class CreateTableStatemen
  
          clusteringColumns.forEach(column ->
          {
 -            CQL3Type type = columns.remove(column);
 +            ColumnProperties columnProperties = columns.remove(column);
              boolean reverse = !clusteringOrder.getOrDefault(column, true);
 -            clusteringTypes.add(reverse ? 
ReversedType.getInstance(type.getType()) : type.getType());
 +            clusteringColumnProperties.add(reverse ? 
columnProperties.withReversedType() : columnProperties);
          });
  
-         if (clusteringOrder.size() > clusteringColumns.size())
-             throw ire("Only clustering columns can be defined in CLUSTERING 
ORDER directive");
+         List<ColumnIdentifier> nonClusterColumn = 
clusteringOrder.keySet().stream()
+                                                                  .filter((id) 
-> !clusteringColumns.contains(id))
+                                                                  
.collect(Collectors.toList());
+         if (!nonClusterColumn.isEmpty())
+         {
+             throw ire("Only clustering key columns can be defined in 
CLUSTERING ORDER directive: " + nonClusterColumn + " are not clustering 
columns");
+         }
  
          int n = 0;
          for (ColumnIdentifier id : clusteringOrder.keySet())


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

Reply via email to