Class UniqueConstraint

java.lang.Object
dev.frostlake.metastore.model.UniqueConstraint

public class UniqueConstraint extends Object
One UNIQUE constraint, spanning one or more columns.

Frostlake enforces uniqueness through a per-column flag on TableColumn; this record sits ALONGSIDE those flags and remembers the two things a boolean flag cannot express — the name an explicit CONSTRAINT <name> UNIQUE (...) clause gave the constraint, and the fact that several columns belong to ONE constraint rather than to one constraint each. A bare column-level UNIQUE needs neither, so it has no record; Table.uniqueConstraintName(String) names it instead and Table.getUniqueConstraints() synthesizes its single-column entry.

  • Constructor Details

    • UniqueConstraint

      public UniqueConstraint(String constraintName, List<String> columnNames)
      Parameters:
      constraintName - the name from an explicit CONSTRAINT <name> clause; null or blank when the constraint was declared without one, in which case it is auto-named SYS_CONSTRAINT_<uuid> the way Snowflake does (see ConstraintNames).
  • Method Details

    • getConstraintName

      public String getConstraintName()
    • setConstraintName

      public void setConstraintName(String constraintName)
      Rename it in place — ALTER TABLE … RENAME CONSTRAINT.
    • getColumnNames

      public List<String> getColumnNames()
    • covers

      public boolean covers(String columnName)
      True when this constraint spans the named column (case-insensitively).
    • renameColumn

      public void renameColumn(String oldName, String newName)
      Follow a column rename: the constraint is unchanged, only the name of a column it spans moved.
    • toString

      public String toString()
      Overrides:
      toString in class Object