Skip to main content
Glama

audit_compaction_debt

Read-onlyIdempotent

Analyze Delta Lake file-size distribution to detect small-file fragmentation debt and generate targeted OPTIMIZE, ZORDER, clustering, and TBLPROPERTIES SQL for faster queries.

Instructions

Evaluate Delta Lake table file-size distribution for small-file fragmentation debt and synthesize targeted OPTIMIZE, ZORDER BY, Liquid Clustering, and TBLPROPERTIES SQL commands.

Usage Guidelines:

  • Use when troubleshooting slow Delta Lake queries, read amplification, or excessive metadata overhead.

  • Prerequisites: Obtain file sizes in bytes (e.g. from DESCRIBE DETAIL table_name, Delta transaction logs, or cloud storage inventory).

  • To forecast pipeline compute cluster DBU burn instead, use forecast_dbu_cost.

Behavior:

  • Purely analytical calculation; parses file size array and computes fragmentation statistics.

  • Does NOT connect to cloud object storage or execute the generated OPTIMIZE/ALTER TABLE statements against a live warehouse.

  • Returns small-file ratios, compaction urgency rating, and copy-pasteable SQL remediation scripts.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "table_name": "<table_name>",
      "file_sizes_bytes": "<file_sizes_bytes>"
    },
    "name": "audit_compaction_debt"
  }
}

Input Schema

NameRequiredDescriptionDefault
table_nameYesThree-part Unity Catalog or Delta table name (catalog.schema.table).
file_sizes_bytesYesArray of Parquet data file sizes in bytes from Delta log.
small_file_threshold_mbNoThreshold in MB below which files count as small (default: 32).

Output Schema

NameRequiredDescriptionDefault
table_nameYesAnalyzed Delta table identifier.
total_filesYesTotal number of Parquet files evaluated.
total_size_mbNoTotal table size in megabytes.
recommended_sqlYesTargeted SQL remediation command to compact small files.
small_file_countNoNumber of files smaller than the threshold.
small_file_ratioYesFraction of files that are small (0.0 to 1.0).
compaction_urgencyYesUrgency rating for running OPTIMIZE.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.1.1
    • changedInput schema / properties / table_name / description
      Previous value: -"Three-part Unity Catalog or Delta table name."New value: +"Three-part Unity Catalog or Delta table name (catalog.schema.table)."
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "properties": {
      +    "compaction_urgency": {
      +      "description": "Urgency rating for running OPTIMIZE.",
      +      "enum": [
      +        "CRITICAL",
      +        "HIGH",
      +        "MODERATE",
      +        "LOW",
      +        "OPTIMAL"
      +      ],
      +      "type": "string"
      +    },
      +    "recommended_sql": {
      +      "description": "Targeted SQL remediation command to compact small files.",
      +      "type": "string"
      +    },
      +    "small_file_count": {
      +      "description": "Number of files smaller than the threshold.",
      +      "type": "integer"
      +    },
      +    "small_file_ratio": {
      +      "description": "Fraction of files that are small (0.0 to 1.0).",
      +      "type": "number"
      +    },
      +    "table_name": {
      +      "description": "Analyzed Delta table identifier.",
      +      "type": "string"
      +    },
      +    "total_files": {
      +      "description": "Total number of Parquet files evaluated.",
      +      "type": "integer"
      +    },
      +    "total_size_mb": {
      +      "description": "Total table size in megabytes.",
      +      "type": "number"
      +    }
      +  },
      +  "required": [
      +    "table_name",
      +    "total_files",
      +    "small_file_ratio",
      +    "compaction_urgency",
      +    "recommended_sql"
      +  ],
      +  "type": "object"
      +}
  2. First observedv0.1.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint, idempotentHint, and openWorldHint=false, but the description adds material scope information beyond them: it is a purely analytical calculation that does NOT touch cloud object storage and does NOT execute the generated DDL. It also previews the return payload (small-file ratios, urgency rating, copy-pasteable SQL). Only pagination/output shape detail is left implicit, and an output schema exists.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core purpose, then organized under explicit Usage Guidelines and Behavior headings that make scanning easy. Slightly long for three parameters, but every line carries actionable information with no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only three-parameter analytical tool with a full-coverage schema, annotations, and an output schema, this covers everything an agent needs: what it computes, what it requires as input, what it refuses to do (execute against a warehouse), and which sibling to prefer instead.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents table_name, file_sizes_bytes, and small_file_threshold_mb. The description adds useful context on where to source the file_sizes_bytes array but does not mention the small_file_threshold_mb parameter or its default, so it does not meaningfully exceed the schema baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource: 'Evaluate Delta Lake table file-size distribution for small-file fragmentation debt' and names the exact SQL remediation it synthesizes (OPTIMIZE, ZORDER BY, Liquid Clustering, TBLPROPERTIES). This is clearly distinguishable from siblings like forecast_dbu_cost or the analyze_* tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicit when-to-use triggers (slow Delta Lake queries, read amplification, excessive metadata overhead), a stated prerequisite (obtain file sizes in bytes via DESCRIBE DETAIL, transaction logs, or storage inventory), and a named alternative with the condition that selects it (forecast_dbu_cost for DBU burn forecasting).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.