Skip to main content

onehouse_table_service

Manages a table service — an automated maintenance operation that runs on a specific table. Table services keep tables healthy by clustering data for faster reads, compacting small files, cleaning up old versions, syncing metadata to external catalogs, creating automatic savepoints, and restoring to previous savepoints.

Canonical reference

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

Example Usage​

Clustering service​

resource "onehouse_table_service" "cluster_events" {
lake = onehouse_lake.warehouse.name
database = onehouse_database.events.name
table = "raw_events"
service = "CLUSTER"

with_options = {
"cluster.field.names" = "event_date,tenant_id"
"cluster.layout.strategy" = "linear"
"cluster.frequency" = "1"
}
}

Compaction service​

resource "onehouse_table_service" "compact_events" {
lake = onehouse_lake.warehouse.name
database = onehouse_database.events.name
table = "raw_events"
service = "COMPACT"

with_options = {
"compaction.max.bytes" = "536870912"
"compaction.frequency" = "1"
}
}

Cleaning service​

resource "onehouse_table_service" "clean_events" {
lake = onehouse_lake.warehouse.name
database = onehouse_database.events.name
table = "raw_events"
service = "CLEAN"

with_options = {
"cleaner.retention.days" = "7"
"cleaner.frequency" = "1"
}
}

Autosavepoint service​

resource "onehouse_table_service" "savepoint_events" {
lake = onehouse_lake.warehouse.name
database = onehouse_database.events.name
table = "raw_events"
service = "AUTOSAVEPOINT"
}

Restore service (on-demand)​

resource "onehouse_table_service" "restore_events" {
lake = onehouse_lake.warehouse.name
database = onehouse_database.events.name
table = "raw_events"
service = "RESTORE"
trigger_mode = "ON_DEMAND"
}

Metasync service (on-demand)​

resource "onehouse_table_service" "metasync_events" {
lake = onehouse_lake.warehouse.name
database = onehouse_database.events.name
table = "raw_events"
service = "METASYNC"
trigger_mode = "ON_DEMAND"

with_options = {
"metasync.catalogs" = "prod-glue"
}
}

Argument Reference​

ArgumentTypeRequiredMutabilityDescription
lakestring✅ImmutableLake name.
databasestring✅ImmutableDatabase name.
tablestring✅ImmutableTable name.
servicestring✅ImmutableService type: CLUSTER, COMPACT, CLEAN, METASYNC, AUTOSAVEPOINT, or RESTORE.
trigger_modestringMutableAUTOMATIC (default) or ON_DEMAND. Valid for all service types. Changes issue ALTER TABLE_SERVICE.
with_optionsmap(string)MutableService-specific configuration parameters. Changes issue ALTER TABLE_SERVICE. → details below

service — when to pick each value​

ValuePurpose
CLUSTERRewrite data files to co-locate records by specified fields, improving read performance for filtered queries.
COMPACTMerge small files into larger ones to reduce file count and improve query performance.
CLEANRemove old file versions beyond the retention period.
METASYNCSync table metadata to external catalogs (Glue, Hive, Unity, etc.).
AUTOSAVEPOINTAutomatically create savepoints (bookmarks) for point-in-time recovery.
RESTORERestore a table to a previous savepoint.

with_options​

A map of string key-value pairs that configure the service. Keys vary by service type:

CLUSTER options​

KeyDescription
cluster.field.namesComma-separated column names to cluster by.
cluster.layout.strategyLayout strategy (e.g. linear).
cluster.frequencyHow often to run (in number of commits).
cluster.bootstrapWhether to cluster existing data on first run.

COMPACT options​

KeyDescription
compaction.max.bytesTarget file size in bytes.
compaction.frequencyHow often to run (in number of commits).

CLEAN options​

KeyDescription
cleaner.retention.daysNumber of days to retain old file versions.
cleaner.frequencyHow often to run (in number of commits).

METASYNC options​

KeyDescription
metasync.catalogsComma-separated catalog names to sync to.

Additional catalog-specific Iceberg keys may be required depending on the target catalog.

Attribute Reference​

AttributeTypeDescription
idstringComposite identifier <lake>/<database>/<table>/<service>.

Import​

Import IDs are composite: <lake>/<database>/<table>/<service>.

terraform import onehouse_table_service.cluster_events warehouse/events/raw_events/CLUSTER

Data Source​

data "onehouse_table_service" "lookup" {
lake = "warehouse"
database = "events"
table = "raw_events"
service = "CLUSTER"
}

output "trigger_mode" {
value = data.onehouse_table_service.lookup.trigger_mode
}

The data source also exposes a status computed attribute reflecting the current service status.

Limitations​

  • with_options not echoed by DESCRIBE. After import or on Read, with_options values are preserved from prior Terraform state since the server does not return them in the DESCRIBE response. Supply all with_options in your .tf file before the first terraform apply after import.
  • One service per type per table. Each table can have at most one service of each type.