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
| Method | Description |
|---|---|
create_table_service | Attach a service to a table |
alter_table_service | Change a service's trigger mode or options |
alter_services_cluster_in_table | Move a table's services to a different cluster |
run_service_in_table | Trigger a service run on demand |
alter_service_in_table | Enable, disable, or configure a service, including autosavepoint and restore |
delete_table_service | Remove a service from a table |
pause_table_service | Pause a service |
resume_table_service | Resume a paused service |
cancel_table_service | Cancel a running clustering service |
describe_table_service | Show full configuration for a service |
show_table_services | List all services on a table |
show_runs_in_table_service | List 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,
)
| Parameter | Required | Type / values |
|---|---|---|
lake | yes | str |
database | yes | str |
table | yes | str |
service | yes | "CLUSTER", "COMPACT", "CLEAN", "METASYNC" |
trigger_mode | no | "AUTOMATIC", "ON_DEMAND" |
options | no | Mapping[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,
)
| Parameter | Required | Type / values |
|---|---|---|
table | yes | str (positional) |
lake | yes | str |
database | yes | str |
service | yes | "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.
| Parameter | Required | Type / values |
|---|---|---|
table | yes | str (positional) |
lake | yes | str |
database | yes | str |
service | yes | "CLUSTER", "COMPACT", "CLEAN", "METASYNC", "AUTOSAVEPOINT", "RESTORE" |
enabled | yes | bool |
trigger_mode | yes | "AUTOMATIC", "ON_DEMAND" |
options | no | Mapping[str, str] — ignored by the server when enabled=False |
The SDK raises ValueError before sending when:
enabledis not abool.enabled=FalsewithAUTOSAVEPOINTorRESTORE; those services cannot be disabled.service="AUTOSAVEPOINT"withoutsavepoint.frequencyinoptions.
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",
)