XieJiann commented on code in PR #27627:
URL: https://github.com/apache/doris/pull/27627#discussion_r1409019971
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/TableIf.java:
##########
@@ -153,6 +156,80 @@ default int getBaseColumnIdxByName(String colName) {
void write(DataOutput out) throws IOException;
+ default Map<String, Constraint> getConstraintMap() {
+ throw new RuntimeException("Not implemented constraint for table " +
this.toString());
+ }
+
+ // Note this function is not thread safe
+ default void checkConstraintNotExistence(String name, Constraint
primaryKeyConstraint,
+ Map<String, Constraint> constraintMap) {
+ if (constraintMap.containsKey(name)) {
+ throw new RuntimeException(String.format("Constraint name %s has
existed", name));
+ }
+ for (Map.Entry<String, Constraint> entry : constraintMap.entrySet()) {
+ if (entry.getValue().equals(primaryKeyConstraint)) {
+ throw new RuntimeException(String.format(
+ "Constraint %s has existed, named %s",
primaryKeyConstraint, entry.getKey()));
+ }
+ }
+ }
+
+ default void addUniqueConstraint(String name, ImmutableList<Column>
columns) {
+ writeLock();
+ try {
+ Map<String, Constraint> constraintMap = getConstraintMap();
Review Comment:
The set can handle repeat column case
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]