lightspeed/pipeline/quality

Data-quality and schema-evolution contracts for ETL pipeline boundaries.

Types

Named boundary value.

pub type BoundaryValue {
  BoundaryValue(name: String, value: Value)
}

Constructors

  • BoundaryValue(name: String, value: Value)

One schema field contract.

pub type Field {
  Field(name: String, kind: FieldType, required: Bool)
}

Constructors

  • Field(name: String, kind: FieldType, required: Bool)

Boundary field type.

pub type FieldType {
  StringType
  IntType
  BoolType
}

Constructors

  • StringType
  • IntType
  • BoolType

One versioned schema boundary.

pub type Schema {
  Schema(name: String, version: Int, fields: List(Field))
}

Constructors

  • Schema(name: String, version: Int, fields: List(Field))

Validation error for one payload/schema pair.

pub type ValidationError {
  InvalidSchema(reason: String)
  MissingField(field: String)
  UnexpectedField(field: String)
  TypeMismatch(
    field: String,
    expected: FieldType,
    actual: String,
  )
}

Constructors

  • InvalidSchema(reason: String)
  • MissingField(field: String)
  • UnexpectedField(field: String)
  • TypeMismatch(field: String, expected: FieldType, actual: String)

Validation result.

pub type ValidationResult {
  ValidationPassed(normalized: List(BoundaryValue))
  ValidationFailed(errors: List(ValidationError))
}

Constructors

Typed value at one boundary.

pub type Value {
  StringValue(String)
  IntValue(Int)
  BoolValue(Bool)
  NullValue
}

Constructors

  • StringValue(String)
  • IntValue(Int)
  • BoolValue(Bool)
  • NullValue

Values

pub fn bool_value(name: String, value: Bool) -> BoundaryValue

Build one named boolean value.

pub fn check_compatibility(
  previous: Schema,
  next: Schema,
) -> Result(Nil, String)

Check whether next is compatibility-safe relative to previous.

pub fn field(
  name: String,
  kind: FieldType,
  required: Bool,
) -> Field

Build one field contract.

pub fn field_type_label(kind: FieldType) -> String

Field-type label.

pub fn int_value(name: String, value: Int) -> BoundaryValue

Build one named integer value.

pub fn null_value(name: String) -> BoundaryValue

Build one named null value.

pub fn schema(
  name: String,
  version: Int,
  fields: List(Field),
) -> Schema

Build one schema contract.

pub fn schema_signature(schema: Schema) -> String

Stable schema signature.

pub fn string_value(name: String, value: String) -> BoundaryValue

Build one named string value.

pub fn valid_schema(schema: Schema) -> Bool

Validate schema invariants.

pub fn validate(
  schema: Schema,
  payload: List(BoundaryValue),
) -> ValidationResult

Validate one payload against one schema contract.

pub fn validation_error_label(error: ValidationError) -> String

Validation-error label.

pub fn validation_result_label(
  result: ValidationResult,
) -> String

Validation-result label.

pub fn value_label(value: Value) -> String

Value label.

Search Document