Class CheckConstraint

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

public class CheckConstraint extends Object
A CHECK constraint: a boolean expression every written row must not make FALSE. Unlike the primary, unique and foreign keys — which Snowflake records but does not enforce — this one IS enforced, on INSERT, UPDATE and MERGE alike (live-verified). Rows already in the table when it is added are left alone, which is what ENABLE NOVALIDATE says.

The expression is kept as the TEXT it was written as, because that text is what every readback surface shows: DESCRIBE's check cell, GET_DDL's constraint line and the violation message all quote it verbatim, case and spacing included.

  • Constructor Details

    • CheckConstraint

      public CheckConstraint(String name, String expression, boolean autoNamed, List<String> referencedColumns)
      Parameters:
      name - the constraint's name — an explicit one, or a generated SYS_CONSTRAINT_*
      expression - the boolean expression, verbatim as written
      autoNamed - whether the name was generated rather than written (live quotes those in the violation message and leaves an explicit name bare)
      referencedColumns - the table columns the expression names, in the order it names them
  • Method Details

    • getName

      public String getName()
    • getExpression

      public String getExpression()
    • isAutoNamed

      public boolean isAutoNamed()
    • getReferencedColumns

      public List<String> getReferencedColumns()
    • getReportedName

      public String getReportedName()
      How a violation names this constraint: an explicit name bare, a generated one in quotes.
    • describedColumn

      public String describedColumn()
      The single column DESCRIBE hangs this check on, or null when there is not exactly one. A check spanning two columns appears in NO column's cell, and neither does one naming none (live-verified).