Skip to main content

Table services

Manage table services that run on Onehouse tables: clustering, compaction, cleaning, metasync, and (for run_service_in_table and alter_service_in_table only) autosavepoint and restore.

Most methods take the same key arguments — lake, database, table, and service. The valid service values are "CLUSTER", "COMPACT", "CLEAN", "METASYNC". The exceptions are run_service_in_table and alter_service_in_table, which also accept "AUTOSAVEPOINT" and "RESTORE", and cancel_table_service, which accepts only "CLUSTER".

Methods​

MethodDescription
create_table_serviceAttach a service to a table
alter_table_serviceChange a service's trigger mode or options
alter_services_cluster_in_tableMove a table's services to a different cluster
run_service_in_tableTrigger a service run on demand
alter_service_in_tableEnable, disable, or configure a service, including autosavepoint and restore
delete_table_serviceRemove a service from a table
pause_table_servicePause a service
resume_table_serviceResume a paused service
cancel_table_serviceCancel a running clustering service
describe_table_serviceShow full configuration for a service
show_table_servicesList all services on a table
show_runs_in_table_serviceList runs for one service

create_table_service​

create_table_service(
*,
lake: str,
database: str,
table: str,
service: str,
trigger_mode: str | None = None,
options: Mapping[str, str] | None = None,
unsafe_raw: bool = False,
timeout: float | None = None,
poll_interval: float | None = None,
)
ParameterRequiredType / values
lakeyesstr
databaseyesstr
tableyesstr
serviceyes"CLUSTER", "COMPACT", "CLEAN", "METASYNC"
trigger_modeno"AUTOMATIC", "ON_DEMAND"
optionsnoMapping[str, str]

Example​

client.create_table_service(
lake="analytics",
database="events",
table="page_views",
service="COMPACT",
trigger_mode="AUTOMATIC",
)

alter_table_service​

alter_table_service(
*,
lake: str,
database: str,
table: str,
service: str,
trigger_mode: str,
options: Mapping[str, str] | None = None,
unsafe_raw: bool = False,
timeout: float | None = None,
poll_interval: float | None = None,
)

trigger_mode is required here (unlike create_table_service).

Example​

client.alter_table_service(
lake="analytics",
database="events",
table="page_views",
service="COMPACT",
trigger_mode="ON_DEMAND",
)

alter_services_cluster_in_table​

alter_services_cluster_in_table(
table: str,
*,
lake: str,
database: str,
services_cluster: str,
unsafe_raw: bool = False,
timeout: float | None = None,
poll_interval: float | None = None,
)

table is positional here.

Example​

client.alter_services_cluster_in_table(
"page_views",
lake="analytics",
database="events",
services_cluster="services-v2",
)

run_service_in_table​

run_service_in_table(
table: str,
*,
lake: str,
database: str,
service: str,
unsafe_raw: bool = False,
timeout: float | None = None,
poll_interval: float | None = None,
)
ParameterRequiredType / values
tableyesstr (positional)
lakeyesstr
databaseyesstr
serviceyes"CLUSTER", "COMPACT", "CLEAN", "METASYNC", "AUTOSAVEPOINT", "RESTORE"

Example​

client.run_service_in_table(
"page_views",
lake="analytics",
database="events",
service="CLEAN",
)

alter_service_in_table​

alter_service_in_table(
table: str,
*,
lake: str,
database: str,
service: str,
enabled: bool,
trigger_mode: str,
options: Mapping[str, str] | None = None,
unsafe_raw: bool = False,
timeout: float | None = None,
poll_interval: float | None = None,
)

Builds ALTER SERVICE IN TABLE. Unlike alter_table_service, it can turn a service off and accepts AUTOSAVEPOINT and RESTORE. See ALTER SERVICE IN TABLE for the options each service takes.

ParameterRequiredType / values
tableyesstr (positional)
lakeyesstr
databaseyesstr
serviceyes"CLUSTER", "COMPACT", "CLEAN", "METASYNC", "AUTOSAVEPOINT", "RESTORE"
enabledyesbool
trigger_modeyes"AUTOMATIC", "ON_DEMAND"
optionsnoMapping[str, str] — ignored by the server when enabled=False

The SDK raises ValueError before sending when:

  • enabled is not a bool.
  • enabled=False with AUTOSAVEPOINT or RESTORE; those services cannot be disabled.
  • service="AUTOSAVEPOINT" without savepoint.frequency in options.

Examples​

# Turn compaction off
client.alter_service_in_table(
"page_views", lake="analytics", database="events",
service="COMPACT", enabled=False, trigger_mode="AUTOMATIC",
)

# Take a savepoint every Sunday at 02:30
client.alter_service_in_table(
"page_views", lake="analytics", database="events",
service="AUTOSAVEPOINT", enabled=True, trigger_mode="AUTOMATIC",
options={
"savepoint.frequency": "weekly",
"savepoint.frequency.week.day": "sunday",
"savepoint.frequency.hour": "2",
"savepoint.frequency.minute": "30",
},
)

delete_table_service​

delete_table_service(*, lake, database, table, service, unsafe_raw=False, timeout=None, poll_interval=None)

service is one of "CLUSTER", "COMPACT", "CLEAN", "METASYNC".

Example​

client.delete_table_service(
lake="analytics", database="events", table="page_views", service="COMPACT",
)

pause_table_service​

pause_table_service(*, lake, database, table, service, unsafe_raw=False, timeout=None, poll_interval=None)

Example​

client.pause_table_service(
lake="analytics", database="events", table="page_views", service="COMPACT",
)

resume_table_service​

resume_table_service(*, lake, database, table, service, unsafe_raw=False, timeout=None, poll_interval=None)

Example​

client.resume_table_service(
lake="analytics", database="events", table="page_views", service="COMPACT",
)

cancel_table_service​

cancel_table_service(*, lake, database, table, service, unsafe_raw=False, timeout=None, poll_interval=None)

Only clustering runs can be cancelled: service must be "CLUSTER". Any other value raises ValueError unless you pass unsafe_raw=True.

Example​

client.cancel_table_service(
lake="analytics", database="events", table="page_views", service="CLUSTER",
)

describe_table_service​

describe_table_service(*, lake, database, table, service, unsafe_raw=False, timeout=None, poll_interval=None)

Example​

result = client.describe_table_service(
lake="analytics", database="events", table="page_views", service="COMPACT",
)

show_table_services​

show_table_services(*, lake, database, table, unsafe_raw=False, timeout=None, poll_interval=None)

Example​

result = client.show_table_services(
lake="analytics", database="events", table="page_views",
)

show_runs_in_table_service​

show_runs_in_table_service(*, lake, database, table, service, unsafe_raw=False, timeout=None, poll_interval=None)

Example​

result = client.show_runs_in_table_service(
lake="analytics", database="events", table="page_views", service="COMPACT",
)