feat(spark-3.5): [stacked] Add ANALYZE TABLE ... COMPUTE CLUSTERING QUALITY SQL extension - #663
Draft
mkuchenbecker wants to merge 1 commit into
Draft
Conversation
mkuchenbecker
force-pushed
the
mkuchenb/spark35-sql-analyze
branch
from
July 24, 2026 19:59
1ccaeb7 to
3dd5f4d
Compare
8 tasks
…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
force-pushed
the
mkuchenb/spark35-sql-analyze
branch
from
July 31, 2026 23:25
404a617 to
b7030eb
Compare
mkuchenbecker
force-pushed
the
mkuchenb/spark35-sql-optimize
branch
from
July 31, 2026 23:25
73088a6 to
1add93d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenHouse spark-3.5 SQL Extensions Stack
mainSummary
Adds a read-only clustering-quality probe to the OpenHouse spark-3.5 SQL extensions:
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 commitand no property write. Emits
(metric, dimension, value)rows:clustering_configured;config_id/keys/sort_mode;coverage_bytes_pct/coverage_files_pct; per-keydepth_avg/depth_p90/depth_maxand the_coveredvariants (Snowflake-stylestabbing 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 — bothdistributed SQL, so the command is safe on tables with very large file counts.
Implemented as
AnalyzeClusteringQualityExec, reusing theoptimize.cluster.*contractfrom OPTIMIZE, with an OpenHouse-table guard. Routing intercepts only the
COMPUTE CLUSTERING QUALITYvariant, so ordinaryANALYZE TABLE … COMPUTE STATISTICSstill delegates to Spark.
Changes
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 STATISTICSdelegation,non-OpenHouse rejection — 5 tests.
Additional Information