fix: match SPARK-60262 when two requested fields select one Parquet field #7820
All Vouch review confidence checks passed
Residual risk 0.28 = Change Risk (0.52) × (1 − Review Confidence (0.47)).
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.02 · 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.344
Real PR Conversation Timeline
1 comments
"Review active on #7820"
general
weight: 0.35
comphead
Which issue does this PR close?
Closes #7819.
Rationale for this change
SPARK-60262 (apache/spark#59510) is in Spark 4.0.5, 4.1.4, 4.2.1 and 4.3.0. With
spark.sql.parquet.fieldId.read.enabled=true,ParquetReadSupportnow fails the read withPARQUET_FIELD_REQUESTED_MORE_THAN_ONCEwhen two requested fields of one group, the root or a struct, resolve to the same Parquet field. That covers a field matched by id plus one matched by name, and two fields with the same id. Earlier releases read without an error.Comet's native scan resolves these fields itself (#7196). It gave the file column to the id match and NULL to the name match, so on a Spark with SPARK-60262 Spark fails the read where Comet returned rows. The
Parquet field claimstests compare Comet with Spark's own read, so on such a Spark most of them fail in that read, before Comet runs.The conflict depends on the file's own schema, so scan planning cannot see it, and nothing in the plan tells Comet which behavior applies. Comet picks it by Spark version, as #7171 and #7522 do for other Spark fixes.
What changes are included in this PR?
SparkFixes.failsOnFieldRequestedMoreThanOnceholds the version check: 4.0.5+, 4.1.4+, 4.2.1+ and 4.3+, the same releases as the other fixes there.NativeScanCommon.fail_on_field_requested_more_than_oncecarries it to the native scan.CometNativeScansets it when field-id reads are on and the check holds, and it reachesSparkParquetOptionsthroughinit_datasource_exec.FieldResolverfinds the first file field that a second requested field selects, and every requested field that selects it, in request order. Spark does the same incheckNoFieldRequestedMoreThanOnceonce it has clipped every requested field of the group, so the error is raised at the point where Spark raises it:- A nested group records it in
FieldMatches, andcheck_nested_conversionraises it after the sibling verdicts. A rejection of a field's shape still comes first, as in Spark, where clipping a struct over a primitive column fails with "is not a group". A deferred leaf rejection, which Spark raises only while it decodes, comes after it. The runtime struct conversion raises it before it converts a value.- The root is checked against the required roots in
check_file_conversions, after the per-column checks. The scan's own adapter resolves against every root of the data schema, which Spark's pruned requested schema does not hold, so it never raises it. The footer step runscheck_file_conversionsfor every file when the option is on.SparkError::ParquetFieldRequestedMoreThanOnceand the Spark 4.xShimSparkErrorConverterbuild Spark'sSparkRuntimeExceptionfrom its error class with Spark's three parameters, becauseQueryExecutionErrors.parquetFieldRequestedMoreThanOnceErroris not in the Spark versions Comet builds against. It is wrapped inFAILED_READ_FILE.NO_HINTlike the duplicate field id error next to it.CometNativeReaderSuite:whenSparkReadsruns a comparison with Spark only when Spark can read the file. When Spark fails with the new error, the test checks that Comet fails with the same message instead, from the native reader or, where the test expects a fallback, from Spark. The tests of a losing container and of a single-column projection over repeated ids need no change: Spark fails them earlier with its own error, or does not see the conflict.parquet.mddescribes the behavior by release.How are these changes tested?
field_resolver.rsfollow Spark's own tests for the error: an id match and a name match in either order and in a case-sensitive read, two fields with one id around an unrelated field, every requester named in request order, no error for fields that select different or no file fields, backticks doubled in the message, and the precedence of a selection error over this one. Tests inschema_adapter.rscover the order of a nested group's errors (shape first, deferred leaf after) and a root check that uses only the required roots.error.rschecks the new error's full message against Spark's template, and its JSON parameters, error class and exception class.SparkFixesSuitepins the version boundaries of the new check with the other three that share its releases.CometNativeReaderSuite(184 tests) passes on Spark 3.5.9, 4.0.4, 4.0.5, 4.1.3, 4.1.4, 4.2.0 and 4.2.1, run on this change before it was rebased ontomainat785e96170. On 4.0.5, 4.1.4 and 4.2.1, which have SPARK-60262, the tests whose requested schema holds both fields read the file with Spark first, and the log of the 4.2.1 run holds Spark'sSparkRuntimeExceptionand Comet's native error for the same fields, whichwhenSparkReadscompares. 3.5.9 needswhenSparkReadsto capture the error in avar, becausewithSQLConfreturnsUnitbefore Spark 4.0, and its run used that form.cargo testfor the native workspace passed apart from the fiveparquet::objectstore::http_metricstests, which bind a loopback listener and could not do so where they ran,cargo fmt --all -- --checkandcargo clippy --all-targets --workspace -- -D warningswere clean, and the scalafix check (-Pspark-4.1 clean compile test-compile scalafix:scalafix -Psemanticdb -Dscalafix.mode=CHECK) passed.mainat785e96170:cargo fmt --all -- --checkis clean,cargo check --all-targetspasses fordatafusion-cometanddatafusion-comet-common, and the Scalatest-compile, with scalastyle and spotless, passes on the default profile and on-Pspark-3.5. The tests have not run since the rebase, so this PR's CI is their first run on top of currentmain.