aokolnychyi commented on code in PR #50561: URL: https://github.com/apache/spark/pull/50561#discussion_r2040494615
########## sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/TableChange.java: ########## @@ -787,4 +803,82 @@ public int hashCode() { return Arrays.hashCode(clusteringColumns); } } + + /** A TableChange to alter table and add a constraint. */ + final class AddConstraint implements TableChange { + private final Constraint constraint; + private final String validatedTableVersion; + + private AddConstraint(Constraint constraint, boolean validate) { + this.constraint = constraint; + this.validatedTableVersion = null; + } + + public Constraint constraint() { + return constraint; + } + + public String validatedTableVersion() { + return validatedTableVersion; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + AddConstraint that = (AddConstraint) o; + return constraint.equals(that.constraint) && + Objects.equals(validatedTableVersion, that.validatedTableVersion); + } + + @Override + public int hashCode() { + return Objects.hash(constraint, validatedTableVersion); + } + } + + /** A TableChange to alter table and drop a constraint. */ + final class DropConstraint implements TableChange { + private final String name; + private final boolean ifExists; + private final Mode mode; + + /** + * Defines modes for dropping a constraint. + * <p> + * RESTRICT - Prevents dropping a constraint if it is referenced by other objects. + * CASCADE - Automatically drops objects that depend on the constraint. + */ + public enum Mode { RESTRICT, CASCADE } + + private DropConstraint(String name, boolean ifExists, Mode mode) { + this.name = name; + this.ifExists = ifExists; + this.mode = mode; + } + + public String name() { + return name; + } + + public boolean isIfExists() { Review Comment: +1 -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org