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.
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.
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
| Argument | Type | Required | Mutability | Description |
|---|---|---|---|---|
name | string | ✅ | Immutable | Validation name. Must be lowercase. SQL lookup key. |
type | string | ✅ | Immutable | One 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
| Value | Use when | Block |
|---|---|---|
schema | You want to validate records against a target schema. → details | schema {} |
timestamp | You want to validate a timestamp field's format and/or its allowed range. → details | timestamp {} |
schema {} block
| Argument | Type | Required | Description |
|---|---|---|---|
target_schema_name | string | ✅ | Name of the target schema to validate ingested records against. |
timestamp {} block
| Argument | Type | Required | Description |
|---|---|---|---|
field | string | ✅ | Name of the timestamp field to validate. |
format | string | ✅ | Expected timestamp format, e.g. yyyy-MM-dd, EPOCH_SECONDS, EPOCH_MILLIS. Validated server-side against the allowed set. |
expected_range | block | ✅ | Range constraint for the field. See below. |
expected_range {} block
| Argument | Type | Required | Description |
|---|---|---|---|
type | string | ✅ | One of no_range, relative, specific. Selects which sub-block (if any) applies. |
relative | block | when type = "relative" | Relative-range constraint. → details |
specific | block | when type = "specific" | Specific-date constraint. → details |
no_range takes no sub-block.
relative {} block
| Argument | Type | Required | Description |
|---|---|---|---|
filter | string | ✅ | is_not_future (timestamp must not be in the future) or is_in_last (timestamp must be within a recent window). |
is_in_last | block | when filter = "is_in_last" | The recent window. See below. |
is_in_last {} block
| Argument | Type | Required | Description |
|---|---|---|---|
quantity | number | ✅ | Positive number of time units. |
unit | string | ✅ | Time unit: HOURS, DAYS, MONTHS, or YEARS. |
specific {} block
| Argument | Type | Required | Description |
|---|---|---|---|
filter | string | ✅ | Comparator: LT, LEQ, GT, or GEQ. |
date | string | ✅ | Date to compare against, in yyyy-MM-dd format. |
Attribute Reference
| Attribute | Type | Description |
|---|---|---|
id | string | Validation identifier. Equal to name. |
uid | string | Server-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
namevalues. - One block per resource. Set exactly one type-specific sub-block, matching
type, with the correct nested sub-block for the chosenexpected_range.type.