show_partitions
Display partition details for Iceberg tables in Trino to analyze data distribution and optimize query performance.
Instructions
Show Iceberg table partitions
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:378-401 (handler)MCP tool handler for 'show_partitions' - decorated with @mcp.tool(), defines input schema via Field parameters, contains docstring with return info, and delegates to client.show_partitions()
@mcp.tool(description="Show Iceberg table partitions") def show_partitions( catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), table: str = Field(description="The name of the table"), ) -> str: """Show Iceberg table partitions. The partitions table contains: - partition: Mapping of partition column names to values - record_count: Number of records in partition - file_count: Number of files in partition - total_size: Total size of files in partition - data: Partition range metadata with min/max values and null/nan counts Args: catalog: catalog name schema_name: schema name table: The name of the table Returns: str: JSON-formatted table partitions """ return client.show_partitions(catalog, schema_name, table) - src/trino_client.py:482-506 (helper)Actual implementation in TrinoClient class - constructs the table identifier with $partitions suffix and executes the query to fetch Iceberg table partition metadata
def show_partitions(self, table: str, catalog: str, schema: str) -> str: """Show Iceberg table partitions. The partitions table contains: - partition: ROW(...) - Mapping of partition column names to values - record_count: BIGINT - Number of records in partition - file_count: BIGINT - Number of files in partition - total_size: BIGINT - Total size of files in partition - data: ROW(...) - Partition range metadata with min/max values and null/nan counts Args: table: The name of the table catalog: Optional catalog name (defaults to configured catalog) schema: Optional schema name (defaults to configured schema) Returns: str: JSON-formatted string containing table partitions """ catalog = catalog or self.config.catalog schema = schema or self.config.schema if not catalog or not schema: raise CatalogSchemaError table_identifier = f"{catalog}.{schema}.{table}$partitions" query = 'SELECT * FROM "{}"' return self.execute_query(query.format(table_identifier)) - src/server.py:378-383 (schema)Input schema definition for 'show_partitions' tool - uses pydantic Field to define catalog, schema_name, and table parameters with descriptions
@mcp.tool(description="Show Iceberg table partitions") def show_partitions( catalog: str = Field(description="catalog name "), schema_name: str = Field(description="schema name "), table: str = Field(description="The name of the table"), ) -> str: