smiklosovic commented on code in PR #3903: URL: https://github.com/apache/cassandra/pull/3903#discussion_r1958633270
########## src/java/org/apache/cassandra/cql3/constraints/ColumnConstraints.java: ########## @@ -101,9 +119,87 @@ public boolean hasRelevantConstraints() return false; } - public void checkInvalidConstraintsCombinations(ColumnIdentifier columnName) + public void checkInvalidConstraintsCombinations(ColumnIdentifier columnName, AbstractType<?> type) { - // TODO check duplicities etc CASSANDRA-20330 + Set<String> constraintNames = new TreeSet<>(); + Set<String> duplicateConstraints = new TreeSet<>(); + List<ColumnConstraint<?>> scalarConstraints = new LinkedList<>(); + for (ColumnConstraint<?> columnConstraint : constraints) + { + String constraintName = columnConstraint.name(); + if (!constraintNames.add(constraintName)) + { + if (columnConstraint.getConstraintType() == ConstraintType.SCALAR) + { + Operator operator = ((ScalarColumnConstraint) columnConstraint).relationType(); + if (operator != NEQ) + duplicateConstraints.add(constraintName); + } + else + { + duplicateConstraints.add(constraintName); + } + } + + if (columnConstraint.getConstraintType() == ConstraintType.SCALAR) + scalarConstraints.add(columnConstraint); + } + + if (!duplicateConstraints.isEmpty()) + throw new InvalidConstraintDefinitionException(format("There are duplicate constraint definitions on column '%s': %s", + columnName, + duplicateConstraints)); + if (scalarConstraints.size() > 2) Review Comment: That should be possible. This patch enables that already, no? We can have more scalars than two. -- 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