Skip to content

Invariants Utility

delta.invariants

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

delta.invariants contains a JSON-encoded SQL expression.

Extracting Constraints from Schema

getFromSchema(
  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:

Rule

Invariants utility defines a Rule abstraction.

Rule has a name.

ArbitraryExpression

ArbitraryExpression is a Rule with the following:

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