Skip to main content

onehouse_validation

Defines a reusable, named validation rule that flows can apply to data as it is ingested into Onehouse tables. A validation is created independently and then referenced by name from one or more flows.

Canonical reference

This page documents Terraform-specific behavior (HCL syntax, types, mutability, drift, import). For full parameter semantics, valid values, and defaults, see CREATE VALIDATION, DESCRIBE VALIDATION, and DELETE VALIDATION.

Names are lowercase

Validation names are lowercased by the backend. Use a lowercase name (e.g. schema_check, not SchemaCheck); the provider rejects mixed-case names at plan time to avoid drift.

Example Usage

Schema validation

Validate ingested records against a target schema.

resource "onehouse_validation" "schema_check" {
name = "schema_check"
type = "schema"
schema {
target_schema_name = "my_target_schema"
}
}

Timestamp — no range

Validate that a field parses as a timestamp in the expected format, with no range restriction.

resource "onehouse_validation" "ts_format" {
name = "ts_format"
type = "timestamp"
timestamp {
field = "event_ts"
format = "yyyy-MM-dd"
expected_range {
type = "no_range"
}
}
}

Timestamp — relative range

Require the timestamp to fall within the last N time units (or to not be in the future).

resource "onehouse_validation" "recent_events" {
name = "recent_events"
type = "timestamp"
timestamp {
field = "event_ts"
format = "yyyy-MM-dd"
expected_range {
type = "relative"
relative {
filter = "is_in_last"
is_in_last {
quantity = 32
unit = "DAYS"
}
}
}
}
}

To require only that the timestamp is not in the future, use filter = "is_not_future" and omit the is_in_last {} block.

Timestamp — specific range

Compare the timestamp against a fixed date.

resource "onehouse_validation" "before_cutoff" {
name = "before_cutoff"
type = "timestamp"
timestamp {
field = "event_ts"
format = "yyyy-MM-dd"
expected_range {
type = "specific"
specific {
filter = "LEQ"
date = "2022-10-12"
}
}
}
}

Argument Reference

Top-level

ArgumentTypeRequiredMutabilityDescription
namestringImmutableValidation name. Must be lowercase. SQL lookup key.
typestringImmutableOne of schema, timestamp. → details below

Exactly one type-specific sub-block must be set, matching the type value. Every argument is immutable (ForceNew) — the API has no ALTER VALIDATION, so any change forces destroy + recreate.

type — when to pick each value

ValueUse whenBlock
schemaYou want to validate records against a target schema. → detailsschema {}
timestampYou want to validate a timestamp field's format and/or its allowed range. → detailstimestamp {}

schema {} block

ArgumentTypeRequiredDescription
target_schema_namestringName of the target schema to validate ingested records against.

timestamp {} block

ArgumentTypeRequiredDescription
fieldstringName of the timestamp field to validate.
formatstringExpected timestamp format, e.g. yyyy-MM-dd, EPOCH_SECONDS, EPOCH_MILLIS. Validated server-side against the allowed set.
expected_rangeblockRange constraint for the field. See below.

expected_range {} block

ArgumentTypeRequiredDescription
typestringOne of no_range, relative, specific. Selects which sub-block (if any) applies.
relativeblockwhen type = "relative"Relative-range constraint. → details
specificblockwhen type = "specific"Specific-date constraint. → details

no_range takes no sub-block.

relative {} block

ArgumentTypeRequiredDescription
filterstringis_not_future (timestamp must not be in the future) or is_in_last (timestamp must be within a recent window).
is_in_lastblockwhen filter = "is_in_last"The recent window. See below.

is_in_last {} block

ArgumentTypeRequiredDescription
quantitynumberPositive number of time units.
unitstringTime unit: HOURS, DAYS, MONTHS, or YEARS.

specific {} block

ArgumentTypeRequiredDescription
filterstringComparator: LT, LEQ, GT, or GEQ.
datestringDate to compare against, in yyyy-MM-dd format.

Attribute Reference

AttributeTypeDescription
idstringValidation identifier. Equal to name.
uidstringServer-assigned validation UID, derived deterministically from the name.

Import

terraform import onehouse_validation.schema_check schema_check

Import is by name. The provider repopulates the full configuration (type and the matching config block) and uid from the server. Enum values are normalized to their canonical form (e.g. comparators as LEQ, units as DAYS), so imports are drift-free.

Data Source

data "onehouse_validation" "lookup" {
name = "schema_check"
}

output "validation_type" {
value = data.onehouse_validation.lookup.type
}

The data source returns id, uid, and type, plus target_schema_name (schema validations) and timestamp_field / timestamp_format (timestamp validations). The full timestamp expected_range configuration is not exposed by the data source.

Limitations

  • No Update. The API has no ALTER VALIDATION — any field change forces destroy + recreate.
  • Lowercase names. Names are lowercased by the backend; the provider rejects mixed-case name values.
  • One block per resource. Set exactly one type-specific sub-block, matching type, with the correct nested sub-block for the chosen expected_range.type.