Metadata-Version: 2.5
Name: icetrace
Version: 0.2.1
Summary: Scan-planning & metadata forensics engine for Apache Iceberg — EXPLAIN ANALYZE for Iceberg metadata without Spark.
Project-URL: Homepage, https://github.com/sanspareilsmyn/icetrace
Project-URL: Repository, https://github.com/sanspareilsmyn/icetrace
Project-URL: Issues, https://github.com/sanspareilsmyn/icetrace/issues
Project-URL: Changelog, https://github.com/sanspareilsmyn/icetrace/blob/main/CHANGELOG.md
Author-email: Sangmin Yoon <sanspareilsmyn@users.noreply.github.com>
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: apache-iceberg,data-engineering,forensics,iceberg,lakehouse,mcp,metadata,query-planning
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Debuggers
Requires-Python: >=3.11
Requires-Dist: mcp>=2.0.0
Requires-Dist: pyarrow>=16.0.0
Requires-Dist: pydantic>=2.7.0
Requires-Dist: pyiceberg[sql-sqlite]>=0.9.0
Requires-Dist: rich>=13.7.0
Requires-Dist: sqlglot>=25.0.0
Requires-Dist: typer>=0.12.0
Provides-Extra: all
Requires-Dist: pyiceberg[gcsfs,glue,hive,s3fs,sql-postgres]>=0.9.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: mypy>=1.11.0; extra == 'dev'
Requires-Dist: pyarrow>=16.0.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.2.0; extra == 'dev'
Requires-Dist: ruff>=0.6.0; extra == 'dev'
Provides-Extra: gcs
Requires-Dist: pyiceberg[gcsfs]>=0.9.0; extra == 'gcs'
Provides-Extra: glue
Requires-Dist: pyiceberg[glue,s3fs]>=0.9.0; extra == 'glue'
Provides-Extra: hive
Requires-Dist: pyiceberg[hive]>=0.9.0; extra == 'hive'
Provides-Extra: s3
Requires-Dist: pyiceberg[s3fs]>=0.9.0; extra == 's3'
Description-Content-Type: text/markdown

# icetrace

**Cut Apache Iceberg query & storage bills in 10 seconds.**

[![PyPI](https://img.shields.io/pypi/v/icetrace.svg)](https://pypi.org/project/icetrace/)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)

Zero data scanned. Read-only. Finds silent pruning bugs, dead snapshot storage, and exact fix ROI — from your terminal, Cursor, or Claude Code.

`icetrace` connects to your catalog (AWS Glue, Polaris, Lakekeeper, Nessie, S3 Tables, Hive, or SQL), reads **only metadata** (zero data files scanned, strictly read-only), and shows you in seconds:

- **Where you're losing money right now** — X-ray an entire database and rank the worst tables `0–100` (`icetrace scan`)
- **Exactly why a query is slow or expensive** — pinpoint silent pruning failures before running another query (`icetrace explain`)
- **What each fix is actually worth** — quantify reclaimable S3 storage (`$/mo`) and projected query scan reduction (`%` & `$/mo`) before paying for a rewrite (`icetrace roi`)

<!-- Replace with your terminal screenshot: docs/assets/hero.png -->
<!-- ![icetrace hero](docs/assets/hero.png) -->

---

## Try It in 5 Seconds (No Credentials Required)

```bash
uvx icetrace demo
```

Or point it straight at your own catalog — read-only, zero infrastructure to deploy:

```bash
# 1. X-ray an entire database: rank worst tables by pruning waste & reclaimable S3 storage
ICETRACE_CATALOG_TYPE=glue icetrace scan --namespace analytics

# 2. Quantify wasted snapshot storage & What-If ROI before running compaction
ICETRACE_CATALOG_TYPE=glue icetrace roi analytics.events

# 3. Debug why a specific WHERE clause scanned too much data
ICETRACE_CATALOG_TYPE=glue icetrace explain analytics.events \
  --where "event_ts >= '2026-11-20' AND tenant_id = 'org_prod_01'"
```

---

## Ask Directly Inside Cursor or Claude Code (MCP)

Keep your SQL, dbt models, or table definitions open and ask in plain English:

> *"Scan our `analytics` database and tell me which 3 Iceberg tables are wasting the most query cost or S3 storage."*  
> *"Why did `WHERE tenant_id = 'org_prod_8491'` scan 180 GB on `analytics.events`, and how much would fixing it save?"*

**Claude Code:**
```bash
claude mcp add --transport stdio --scope user icetrace -- uvx --from "icetrace[glue]" icetrace-mcp
```

**Cursor** (`.cursor/mcp.json` or `~/.cursor/mcp.json`):
```json
{
  "mcpServers": {
    "icetrace": {
      "command": "uvx",
      "args": ["--from", "icetrace[glue]", "icetrace-mcp"],
      "env": {
        "ICETRACE_CATALOG_TYPE": "glue",
        "AWS_PROFILE": "${env:AWS_PROFILE}",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}
```

---

## Why Teams Actually Use This

Query engines (Athena, Trino, Spark, ClickHouse, Snowflake) execute your query and hand you the bill — they don't tell you **why** Iceberg failed to skip files. `icetrace` catches the exact silent traps that cause 10x–100x over-scanning:

- **Columns past #32 have zero bounds** (`MISSING_METRICS_COL_LIMIT`) — Iceberg stops recording min/max stats after column 32 by default.
- **16-char string truncation collisions** (`TRUNCATED_BOUNDS`) — default `truncate(16)` collapses prefixed IDs/URIs (`org_prod_us_east_...`) across every file, turning data skipping to 0%.
- **Compaction destroyed your clustering** (`OVERLAPPING_RANGES`) — binpack or arrival-order writes make every file span the full domain (`overlap = 0.98`).
- **Missing writer stats & interleaved manifests** — catches zero-copy `add_files` jobs that omitted Parquet stats, evolved partition-spec mismatches, and V2/V3 delete-file amplification.
- **Ghost storage in old snapshots** — measures exact historical-only bytes locked in un-expired snapshots.

---

## Install

```bash
# Zero-install (recommended)
uvx icetrace demo

# Homebrew (macOS / Linux)
brew tap sanspareilsmyn/icetrace https://github.com/sanspareilsmyn/icetrace
brew install icetrace

# uv tool (with AWS Glue & S3)
uv tool install "icetrace[glue]"
```

Works out of the box with `~/.pyiceberg.yaml`, `ICETRACE_CATALOG_TYPE` (`glue`, `rest`, `sql`, `hive`), and standard AWS/GCP credentials.

---

## 7 Read-Only Tools (CLI & MCP)

| CLI / MCP Tool | What You Get (Metadata Only) |
|---|---|
| `scan` / `scan_catalog` | Concurrently X-ray all tables in a database, score `0–100`, rank worst offenders by cost & waste. |
| `roi` / `simulate_roi` | Historical snapshot S3 waste (`$/mo`) + What-If scan reduction (`%` & Athena `$/mo`) per fix. |
| `explain` / `explain_scan` | 4-stage pruning funnel (100% parity with PyIceberg `plan_files()`) + per-file root-cause attribution. |
| `audit` / `audit_pruning_health` | Per-column pruning grade (`A–F`), bounds coverage, `truncate(N)` collision %, and $O(N \log N)$ sweep-line overlap ratio. |
| `diff` / `diff_snapshots` | Pinpoint which commit spiked manifests, dropped bounds, or regressed query pruning. |
| `inspect` / `inspect_table_layout` | Instant `metadata.json` view (format version, column ordinals, evolved partition specs, sort order). |
| `tables` / `list_tables` | Catalog & namespace discovery. |

---

## Safe on Production Tables

- **Strictly Read-Only** — never mutates, compacts, or expires tables (`readOnlyHint: true`, `destructiveHint: false`).
- **Zero Data Scanned** — reads only `metadata.json`, manifest lists, and manifest Avro files (16-way concurrent, bounded by `max_manifests`).
- **100% Local** — credentials and metadata never leave your machine.

---

[Roadmap](ROADMAP.md) · [Changelog](CHANGELOG.md) · [Agent Skill](skills/icetrace/SKILL.md) · [Contributing](CONTRIBUTING.md) · Apache-2.0
