optimize_manifests
Optimize manifest files for Iceberg tables to reduce metadata overhead and improve query performance.
Instructions
Optimize manifest files for an Iceberg table
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| catalog | Yes | catalog name | |
| schema_name | Yes | schema name | |
| table | Yes | The name of the table |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/server.py:160-176 (handler)MCP tool handler for 'optimize_manifests' - decorated with @mcp.tool(), defines the tool interface with pydantic Field descriptions for catalog, schema_name, and table parameters. Calls client.optimize_manifests() to execute the operation.
@mcp.tool(description="Optimize manifest files for an Iceberg table") def optimize_manifests( catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), table: str = Field(description="The name of the table"), ) -> str: """Optimize manifest files for an Iceberg table. Args: catalog: catalog name schema_name: schema name table: The name of the table Returns: str: Confirmation message """ return client.optimize_manifests(catalog, schema_name, table) - src/trino_client.py:264-287 (helper)Helper method that executes the actual SQL query 'ALTER TABLE {catalog}.{schema}.{table} EXECUTE optimize_manifests' using the Trino client. Handles catalog/schema defaults and raises CatalogSchemaError if not specified.
def optimize_manifests(self, table: str, catalog: str, schema: str) -> str: """Optimize manifest files for an Iceberg table. This operation reorganizes and compacts the table's manifest files for improved performance. Args: table (str): The name of the table. catalog (Optional[str]): The catalog name. If None, uses configured default. schema (Optional[str]): The schema name. If None, uses configured default. Returns: str: Success message indicating the manifests were optimized. Raises: CatalogSchemaError: If either catalog or schema is not specified and not configured. """ catalog = catalog or self.config.catalog schema = schema or self.config.schema if not catalog or not schema: raise CatalogSchemaError query = f"ALTER TABLE {catalog}.{schema}.{table} EXECUTE optimize_manifests" self.execute_query(query) return f"Manifests for table {catalog}.{schema}.{table} optimized successfully" - src/server.py:162-164 (schema)Inline schema definition using pydantic Field() for the optimize_manifests tool parameters: catalog, schema_name, and table.
catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), table: str = Field(description="The name of the table"), - src/server.py:160-160 (registration)Tool registration via @mcp.tool() decorator with description 'Optimize manifest files for an Iceberg table'
@mcp.tool(description="Optimize manifest files for an Iceberg table")