Skip to content

feat(spark-3.5): [stacked] Add ANALYZE TABLE ... COMPUTE CLUSTERING QUALITY SQL extension - #663

Draft
mkuchenbecker wants to merge 1 commit into
mkuchenb/spark35-sql-optimizefrom
mkuchenb/spark35-sql-analyze
Draft

feat(spark-3.5): [stacked] Add ANALYZE TABLE ... COMPUTE CLUSTERING QUALITY SQL extension#663
mkuchenbecker wants to merge 1 commit into
mkuchenb/spark35-sql-optimizefrom
mkuchenb/spark35-sql-analyze

Conversation

@mkuchenbecker

Copy link
Copy Markdown
Contributor

OpenHouse spark-3.5 SQL Extensions Stack

PR Base Content
#660 main Standalone refactor (decouple spark-3.5 from spark-3.1)
#661 #660 VACUUM
#662 #660 OPTIMIZE (bin-pack + incremental clustering)
(this) #662 ANALYZE … COMPUTE CLUSTERING QUALITY

Depends on #662 (which depends on #660). This reuses the optimize.cluster.* property
contract and helpers introduced by OPTIMIZE, so it stacks on #662 rather than the
standalone refactor. Review/merge #660#662 → this.

Summary

Adds a read-only clustering-quality probe to the OpenHouse spark-3.5 SQL extensions:

ANALYZE TABLE <table> COMPUTE CLUSTERING QUALITY

Reports how well a table is clustered to its current key selection, using only what
OPTIMIZE persists (optimize.cluster.state) plus manifest metrics (t.files). No commit
and no property write.
Emits (metric, dimension, value) rows: clustering_configured;
config_id / keys / sort_mode; coverage_bytes_pct / coverage_files_pct; per-key
depth_avg / depth_p90 / depth_max and the _covered variants (Snowflake-style
stabbing depth, the SLA quality input); null_bound_bytes_pct; unclustered_tail_hours;
state. Coverage is one aggregate over metadata and depth is a windowed sweep — both
distributed SQL, so the command is safe on tables with very large file counts.

Implemented as AnalyzeClusteringQualityExec, reusing the optimize.cluster.* contract
from OPTIMIZE, with an OpenHouse-table guard. Routing intercepts only the
COMPUTE CLUSTERING QUALITY variant, so ordinary ANALYZE TABLE … COMPUTE STATISTICS
still delegates to Spark.

Changes

  • Client-facing API Changes
  • Internal API Changes
  • Bug Fixes
  • New Features
  • Performance Improvements
  • Code Style
  • Refactoring
  • Documentation
  • Tests

New non-reserved keywords ANALYZE / COMPUTE / CLUSTERING / QUALITY.

Testing Done

  • Added new tests for the changes made.

  • AnalyzeClusteringQualityExecTest (metricExpr / coveragePredicate) — 5 tests.

  • AnalyzeClusteringQualityStatementTest (real Iceberg, Hadoop catalog): unconfigured flag,
    post-OPTIMIZE coverage/depth, read-only invariant, COMPUTE STATISTICS delegation,
    non-OpenHouse rejection — 5 tests.

./gradlew :integrations:spark:spark-3.5:openhouse-spark-3.5-runtime_2.12:test            # incl. 5 ANALYZE unit tests
./gradlew :integrations:spark:spark-3.5:openhouse-spark-3.5-itest:statementTest --tests '*AnalyzeClusteringQualityStatementTest'   # 5/5
# both BUILD SUCCESSFUL

Additional Information

  • Large PR broken into smaller PRs, and PR plan linked in the description.

…nsion

Adds a read-only clustering-quality probe to the OpenHouse spark-3.5 SQL
extensions:

  ANALYZE TABLE <table> COMPUTE CLUSTERING QUALITY

Reports how well a table is clustered to its current key selection, using only
what OPTIMIZE persists (optimize.cluster.state) plus manifest metrics (t.files).
No commit and no property write. Emits (metric, dimension, value) rows:
clustering_configured; config_id/keys/sort_mode; coverage_bytes_pct /
coverage_files_pct (fraction whose leading-key range was clustered under the
current config); per-key depth_avg/p90/max and the _covered variants
(Snowflake-style stabbing depth, the SLA quality input); null_bound_bytes_pct;
unclustered_tail_hours; state. Coverage is an aggregate over metadata and depth
is a windowed sweep, both in distributed SQL so the command is safe on tables
with very large file counts.

Implemented as AnalyzeClusteringQualityExec, reusing the optimize.cluster.*
property contract from OptimizeTable, with an OpenHouse-table guard. Routing
intercepts only the COMPUTE CLUSTERING QUALITY variant, so ordinary
ANALYZE TABLE ... COMPUTE STATISTICS still delegates to Spark. New non-reserved
keywords ANALYZE/COMPUTE/CLUSTERING/QUALITY.

Tested by AnalyzeClusteringQualityExecTest (metricExpr/coveragePredicate) and
AnalyzeClusteringQualityStatementTest (real Iceberg, Hadoop catalog: unconfigured
flag, post-OPTIMIZE coverage/depth, read-only invariant, COMPUTE STATISTICS
delegation, non-OpenHouse rejection).

Co-authored-by: Copilot <[email protected]>
@mkuchenbecker
mkuchenbecker force-pushed the mkuchenb/spark35-sql-analyze branch from 404a617 to b7030eb Compare July 31, 2026 23:25
@mkuchenbecker
mkuchenbecker force-pushed the mkuchenb/spark35-sql-optimize branch from 73088a6 to 1add93d Compare July 31, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant