/polymath-streaming:lakehouse-performancefrom polymath-streaming
Tune Databricks/Spark and Delta — small files, OPTIMIZE, clustering, shuffle, skew, Auto Loader, cluster cost. Not lake layout.
Ships in polymath-streaming. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Lakehouse jobs are slow for three reasons: too many small files, too much data shuffled, or one skewed task holding the stage. Read the Spark UI first; tune the table layout before the cluster.
Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.
Not this when: you are choosing the physical lake layout and file formats — polymath-streaming:data-lake-layout; the dimensional model — data-modeling; a single warehouse SQL query on Postgres-like engines — polymath-data:sql-optimize.
DESCRIBE DETAIL and DESCRIBE HISTORY output, write pattern (append, MERGE, streaming micro-batches).Read-only first. Inspect with DESCRIBE DETAIL/HISTORY, query profile, and Spark UI. OPTIMIZE, VACUUM, cluster resizing, and config changes are applied by the owner after review (VACUUM shortens time-travel and can break long-running readers).
OPTIMIZE (target file size is typically hundreds of MB — let the platform defaults apply unless measured) for tables that are append-heavy.delta.dataSkippingStatsColumns/dataSkippingNumIndexedCols. Cluster data by the common predicate: liquid clustering (CLUSTER BY) for new tables — flexible and incremental — or OPTIMIZE … ZORDER BY on older tables (multi-column locality, rewrites more data). Don't also hive-partition the same column.VACUUM to remove unreferenced files (retention default 7 days; keep ≥ the longest reader/stream lag and your time-travel need), and bound the transaction-log history. Deletion vectors speed DELETE/UPDATE/MERGE by avoiding full file rewrites (verify support).broadcast() hint or raise spark.sql.autoBroadcastJoinThreshold thoughtfully; AQE can convert at runtime); filter and project early; pre-aggregate; avoid distinct/groupBy on high-cardinality columns when a window or approximate function will do.spark.sql.shuffle.partitions so each shuffle partition is ~100–200 MB (not the default 200 for a TB-scale shuffle).ON condition so the target files read are pruned (a MERGE without pruning rewrites the table); dedupe the source first (duplicate matches error out and waste time); keep batches reasonably large; use deletion vectors and Photon where available; for CDC use foreachBatch with MERGE and idempotency on a batch/version key.cloudFiles) for incremental file ingestion — file-notification mode over directory listing at scale; define a schema or schema hints plus schemaEvolutionMode; maxFilesPerTrigger/maxBytesPerTrigger to bound batch size; quarantine bad records (_rescued_data). Land raw in bronze with minimal transformation, then incremental transforms downstream.processingTime) only when freshness demands; availableNow (incremental batch on a schedule) is far cheaper for hourly/daily freshness. Always set a checkpoint location (one per stream, never shared or deleted casually); bound state (watermark + TTL; RocksDB state store for large state); monitor input rate vs processing rate and batch duration vs trigger interval (if processing time ≥ interval, it falls behind). Design sinks idempotently (foreachBatch + MERGE, or Delta's exactly-once writes with checkpoint).polymath-database:data-retention-archiving).Lakehouse performance review: silver.orders_enriched nightly job (DBR 15.4, Photon on, 16 × i3.2xlarge)
Symptom: 3 h 10 min (was 55 min in March); cost 3.4× [VERIFY: DBU + cloud].
Evidence
Spark UI: stage 14 (MERGE into silver.orders) = 71% of runtime; 41,000 tasks, median 1.9 s, max 7 min (1 task)
Table: DESCRIBE DETAIL → 380,000 files, avg 9 MB; partitioned by order_id (!); no OPTIMIZE in 90 d
MERGE condition: t.order_id = s.order_id (no cluster/partition pruning on order_date)
Skew: key "unknown_customer" = 11% of source rows
Diagnosis (ranked)
1. Layout: partitioning on a high-cardinality column → 380k small files; MERGE scans all.
2. MERGE without pruning predicate + skewed null-like key.
Changes
1. Rewrite to CLUSTER BY (order_date, customer_id) [liquid clustering], drop order_id partitioning; run OPTIMIZE once; enable predictive optimization/auto compaction.
2. MERGE ON t.order_date = s.order_date AND t.order_id = s.order_id (+ order_date range filter from source min/max); filter 'unknown_customer' to a side path.
3. Job: availableNow incremental instead of full-day reprocess [VERIFY: source supports incremental watermark].
Expected: scan files from 380k to ≈ days-touched × files-per-day; runtime back near baseline — confirm on one night's run before the backfill.
Verify: files scanned in the MERGE, max/median task ratio < 3, spill 0, cost per run.
Not changed: cluster size (task skew, not capacity, is the limit).
Caution: VACUUM retention stays 7 d (downstream stream lags ≤ 2 d).
VACUUM/retention changes consider time travel and long readers.[VERIFY].Z-ORDER on columns that are also partition keys.spark.sql.shuffle.partitions copy-pasted values regardless of data size; disabling AQE without evidence.collect() on large data.VACUUM retention to 0 hours to "free space" while streams or readers lag.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub mohammadbafkar/polymath --plugin polymath-streaming9 skills in this plugin
/azure-event-hubs-designDesign and size Azure Event Hubs — tier, throughput units, partitions, consumer groups, checkpointing, Capture, Kafka endpoint./data-lake-layoutDesign the physical data lake — zones, paths, Parquet and Delta/Iceberg, file sizing, partitioning, compaction, lifecycle tiers./data-modelingModel analytical data — dimensional (star/snowflake) vs normalized vs lakehouse medallion layers, grain, partitioning, slowly-changing dimensions, and schema evolution.Other plugins' skills for the same job