Each contract must contain the following components:
-
spec-version
: The version of Gable’s data contract specification.type
: stringconstraints
: Valid semantic spec version. Currently supported versions are0.1.0
.
-
namespace
: A unique named collection of contracts. This field is meant to be a user-defined space that has meaning within your organization.type
: stringconstraints
:(?=.*[a-zA-Z0-9])[A-Za-z0-9\.\_]
(Must include at least one alphanumeric character,can include special characters.
and_
)
-
name
: The name of the contract which, when combined with the namespace, uniquely identifies the contract.type
: stringconstraints
:(?=.*[a-zA-Z0-9])[a-zA-Z0-9_]
(Must include at least one alphanumeric character, can include special character_
)
-
doc
: Documentation for the contract, can be specified with YAML’s multi-line syntaxtype
: string
-
dataAssetResourceName
: The unique resource name of the data asset this contract covers. See Data Assets for more detailstype
: stringconstraints
: Must be a valid resource name in the format<type>://<source>:<dataset>
-
owner
: The email for the team or individual who owns the data contracttype
: email (string)
-
schema
: The schema definition of the data asset. Gable uses a flexible type system for contract schemas, see the below section on the type specification for more details. At minimum, each field contains a name and type. Types can be primitives, or complex types like unions, lists, and nested objects.-
type
: list[Type] -
constraints
: In the data contract schema, various constraints can be applied to ensure data quality. These constraints define the conditions that the data must satisfy. Below are the detailed descriptions of the supported constraints: -
Warning:
Currently contract constraints only exist forS3
based assetsGREATER_THAN
:- Description: Ensures that the field value is greater than a specified value.
- Applicable To: Number, Time
- Usage:
GREATER_THAN_OR_EQUAL_TO
:- Description: Ensures that the field value is greater than or equal to a specified value.
- Applicable To: Number, Time
- Usage:
LESS_THAN
:- Description: Ensures that the field value is less than a specified value.
- Applicable To: Number, Time
- Usage:
LESS_THAN_OR_EQUAL_TO
:- Description: Ensures that the field value is less than or equal to a specified value.
- Applicable To: Number, Time
- Usage:
IS_NULL
:- Description: Ensures that the field value is null.
- Applicable To: Number, String, Time, Bytes, DataStructure, Other
- Usage:
IS_NULL_THRESHOLD
:- Description: Ensures the null value does not exceed a specified threshold.
- Applicable To: Number, String, Time, Bytes, DataStructure, Other
- Usage:
IS_NOT_EMPTY
:- Description: Ensures the value is not empty.
- Applicable To: String, DataStructure
- Usage:
LENGTH
:- Description: Ensures that the length of the field value is equal to a specified length.
- Applicable To: String, DataStructure
- Usage:
LENGTH_GREATER_THAN
:- Description: Ensures that the length of the field value is greater than a specified length
- Applicable To: String, DataStructure
- Usage:
LENGTH_GREATER_THAN_OR_EQUAL_TO
:- Description: Ensures the length of the value is greater than or equal to a specified length.
- Applicable To: String, DataStructure
- Usage:
LENGTH_LESS_THAN
:- Description: Ensures the length of the value is less than a specified length.
- Applicable To: String, DataStructure
- Usage:
LENGTH_LESS_THAN_OR_EQUAL_TO
:- Description: Ensures the length of the value is less than or equal to a specified length.
- Applicable To: String, DataStructure
- Usage:
-
Example Data Contract Spec
Below is an example of a data contract that enforces the schema forOneBusAway
, an open source project providing public APIs for transit information: