from_protobuf: Return fields the query does not read as nulls on the GPU [databricks] #16697
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 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.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #16697"
general
weight: 0.35
wjxiz1992
Part of #14069. Uses the hidden-field null-column support merged in NVIDIA/cudf-spark-jni#5372.
Description
The GPU
from_protobufdecodes and returns every field of the message, even when the query reads only a few of them. Spark still parses the whole message, so fields the query does not read must keep being validated, but they do not need to be materialized.The planner now traces which fields of the decoded struct the query reads, through struct field and array element accesses in projections, filters, sorts and aggregates. It passes unread fields to the decoder as hidden (
isOutput = false). With NVIDIA/cudf-spark-jni#5372, the decoder still validates hidden fields like Spark does, including those inside nested and repeated messages, but returns them as nulls. So the expression keeps Spark's output type, and no operator above it changes.To preserve Spark semantics across all plans and boundaries:
semanticEquals, so semantically equal copies take the union (keepingGpuTieredProjectCSE intact so semantically equal copies in the same projection decode once) while non-deterministic inputs still trace their own reads instead of hiding every field.required) remain visible under visible parents so Spark'sUnsafeProjection(inGpuCpuBridgeExpressionandGpuColumnarToRowExec) never dereferences nulls innullable = falsestruct slots. Unread nullable messages (optionalandrepeated) still hide their entire subtrees, including nestedrequiredfields.This replaces the schema projection in the draft #14354, which changed the output type of the expression, with a smaller change.
User-facing: none. Results are unchanged; queries that read some of the fields use less GPU memory.
Tests:
ProtobufSchemaSuitecovers merging field reads, JNI schema validation for hidden children of an output message, andFieldReads.analyzePlansacross carriedProjectExec(alias and pass-through),FilterExec,SortExec,HashAggregateExec(grouping, aggregate argument, aggregate filter, and whole-struct grouping),ElementAtwith dynamic index reads,GetArrayItem, unsupported/root boundaries, dropped structs, unmatched fail-closed fallback, and non-deterministic decodes.protobuf_test.pychecks, for each decode in the GPU plan, which fields it outputs: top-level fields, nested leaves, array elements viaget,try_element_at, and array-of-struct extraction, reads through a non-collapsed alias projection, pushed-down and carried filters, sort and aggregate queries, whole-struct/whole-child reads, and non-deterministic inputs.protobuf_test.pyalso verifies that non-nullablerequiredfields stay output under visible parents (while optional children andrequiredfields under hidden optional messages stay hidden) and execute cleanly acrossGpuCpuBridgeExpressionand CPUFilterExecfallback paths.Locally validated on Spark 3.5.2 (
-Dbuildver=352) against the published nightlycudf-spark-jni26.12.0-SNAPSHOT(revisionbd15415531c40a2e83067d91147fcfa51a317b1d):ProtobufSchemaSuite,ProtobufExprShimsSuite, andSparkProtobufCompatSuite: 50 tests passed.TEST_PARALLEL=1 INCLUDE_SPARK_PROTOBUF_JAR=true ./integration_tests/run_pyspark_from_build.sh -k protobuf: 120 tests passed.GpuCpuBridgeExpressionand CPUFilterExecfallback cases on hiddenrequiredschemas with JVM assertions enabled (-ea).mvn -N -Dbuildver=352 -Dspark.rapids.source.basedir=$PWD antrun:run@scalastyle-all-modules: 0 errors, 0 warnings.build/check_shim_compatibility.py coverage: PASS (35 profiles, 4465 checks, 0 findings); GitHub Actionsshim-compatibilityandshim-related-prspassed on headd42def938.Not run locally: other Spark versions (including Scala 2.13) and Databricks runtimes.
Performance: Measured per-task GPU memory peak (
gpuMaxTaskFootprint) with a local benchmark on one RTX 5880 Ada, Spark 3.5.2local[8](measured on commit25d9ef6fprior to mergingmain, the final merged NVIDIA/cudf-spark-jni#5372 snapshot, and keeping non-nullable fields visible under visible parents). The serialized messages come from Spark's CPU cache, so they reach the GPU without a GPU Parquet scan, as from Kafka. Results equal those of the current plugin.| Message | Fields read | Before | After |
|---|---|---|---|
| 50K x 34 KB, nested and repeated messages | 3 of 20 top-level scalars | 340 MiB | 171 MiB |
| | one leaf 3 levels deep | 340 MiB | 171 MiB |
| | one field of a repeated message | 340 MiB | 173 MiB |
| 500K x 1.7 KB, repeated messages | one field of a repeated message | 315 MiB | 184 MiB |
| 1M x 174 B, 3-level nested messages | 2 leaves | 113 MiB | 81 MiB |
When the messages are read from Parquet on the GPU, the scan peak is higher than the decode peak, so the task peak does not change.
Under GPU memory pressure the smaller footprint also saves time. With 8 concurrent GPU tasks and the RMM pool limited to 1 GiB or 768 MiB (
spark.rapids.memory.gpu.allocSize), reading 3 top-level scalars or one field of a repeated message from the 34 KB messages spilled 360-500 MiB and retried allocations 3-5 times per query before this change, taking 0.94-1.32 s (median of 3). After it, those queries did not spill or retry and took 0.69-0.71 s. Reading every field spilled and took the same time with and without the change. With a 1.5 GiB or larger pool, and in the default configuration, query time did not change measurably, from Parquet or from the CPU cache.This change was developed with AI assistance.
Checklists
Documentation
Testing
(Please provide the names of the existing tests in the PR description.)
Performance