Enable key-only range sampling for seeded random clustering keys [databricks] #16252
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 533 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.376
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #16252"
general
weight: 0.35
sdrp713
Fixes #15445 and fixes #16613 .
Description
Enable key only range boundary sampling for the seeded random tie breaker generated by Delta liquid clustering. The existing pruning guard requires all selected projection expressions to be deterministic. As a result, liquid clustering plans containing
GpuRandfall back to reading the full table schema during boundary collection, even whenspark.rapids.sql.rangePartitioning.sampleKeysOnly=true.This change allows
GpuRandwith an integer or long literal seed and GPU expression wrappers whose own evaluation is deterministic. It also tracks filter dependencies through projection aliases and requires those dependencies to remain deterministic. Direct or aliased random filters, unsupported nondeterministic expressions, and unsupported plan nodes retain the existing fallback path.Boundary samples supply advisory split points. The original exchange child and ordering comparator remain unchanged, so output rows and their values still come from the original input plan. Re-evaluating a random sampling key can change approximate partition balance but it does not replace output row values.
Validation
GpuRangeBoundaryPlanSuitefor seeded random keys, expression wrappers, alias dependencies, and unsafe-expression/filter fallbacks.NonDeterministicRetrySuitefor seeded random streams across batch sizes, empty batches, partitions, and checkpoint restoration.GpuRangeBoundaryPlanSuite,NonDeterministicRetrySuite, andProjectSplitRetrySuite, including retry and split-retry coverage.Performance
Reproduced the issue's write workflow: create an empty Delta table clustered by
session_id, clear caches, and append the source. Automatic optimization performs liquid clustering during the append; no separate explicitOPTIMIZEis issued. All runs used the same cloned source pinned to version 0: 5,887,163 rows and 585 columns.The driver was an r7i.2xlarge. Each run used two executors with four Spark cores, 60 GiB heap, and 52 GiB memory overhead. GPU runs used g4dn.8xlarge executors, 2 GiB input partitions, 512 MiB GPU batches, and GPU concurrency 1. The CPU run used the issue's i7i.4xlarge executors and 128 MiB input partitions.
Table properties followed the issue's respective CPU/GPU configurations. Both enabled automatic optimized writes, automatic compaction, checkpoint v2, and statistics on
session_id. CPU additionally enabled deletion vectors, row tracking, change data feed, and name-based column mapping. GPU disabled deletion vectors and left the other three features unset.| Variant | Append including automatic clustering | Initial write | Clustering | GPU boundary collection |
| --- | ---: | ---: | ---: | ---: |
| CPU, original issue settings | 1,349.208 s | 500.064 s | 826.618 s | — |
| GPU, both optimizations disabled | 1,660.069 s | 679.455 s | 970.823 s | 298.207 s |
| GPU, both optimizations enabled | 1,465.430 s | 681.226 s | 773.686 s | 262.007 s |
| GPU, this candidate, both optimizations enabled | 1,213.269 s | 677.774 s | 525.062 s | 2.597 s |
“Both optimizations” refers to
spark.rapids.sql.rangePartitioning.sampleKeysOnlyandspark.rapids.sql.rangeShuffle.inputBatching.enabledfrom #15925 and #15941.Compared with the merged implementation with both optimizations enabled, this candidate reduced boundary collection time by approximately 101×, clustering elapsed time by 32.1%, and total append elapsed time by 17.2%. Total append elapsed time was 26.9% lower than GPU with both optimizations disabled and 10.1% lower than CPU with the original issue's CPU settings. Initial GPU writes remained slower than CPU writes.
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance