https://delta.io logo
f

Felipe Pessoto

08/29/2023, 10:32 PM
Invariant vs Check Constraint They both look the same: https://github.com/delta-io/delta/blob/master/PROTOCOL.md#column-invariants, https://github.com/delta-io/delta/blob/master/PROTOCOL.md#check-constraints Why do we need invariants? Docs also doesn't mention how to add an invariant, only check constraint: https://docs.delta.io/latest/delta-constraints.html
w

Will Jones

08/29/2023, 10:36 PM
Constraints replaced invariants. I've proposed we mark invariants as deprecated, but I don't think that's happened yet.
f

Felipe Pessoto

08/29/2023, 10:40 PM
It also seems to exist a (potentially incorrect or at least not described in the spec) dependency between NOT NULL columns and invariant. If you try to read a table containing not-null columns, and writer version is 7, and writerFeatures doesn't contain "invariants", it throws a validation error: "org.apache.spark.sql.delta.DeltaTableFeatureException: Unable to operate on this table because the following table features are enabled in metadata but not listed in protocol: invariants."
w

Will Jones

08/29/2023, 10:51 PM
That's an interesting point. I don't have any clarity on it yet, but mentioned this discussion in the GH issue: https://github.com/delta-io/delta/issues/1239#issuecomment-1698245202
👍 1