Skip to content

Invariants Utility


Invariants defines delta.invariants for the column invariants of a delta table.

delta.invariants contains a JSON-encoded SQL expression.

Extracting Constraints from Schema

  schema: StructType,
  spark: SparkSession): Seq[Constraint]

getFromSchema finds columns (top-level or nested) that are non-nullable and have delta.invariants metadata.

For every parent of the columns, getFromSchema creates NotNull constraints.

For the columns themselves, getFromSchema creates Check constraints.

getFromSchema is used when:


Invariants utility defines a Rule abstraction.

Rule has a name.


ArbitraryExpression is a Rule with the following:

  • EXPRESSION([expression]) name
  • An Expression (Spark SQL)