snmvaughan commented on code in PR #7820:
URL: https://github.com/apache/datafusion-comet/pull/7820#discussion_r4787500253


##########
spark/src/main/spark-4.x/org/apache/spark/sql/comet/shims/ShimSparkErrorConverter.scala:
##########
@@ -374,6 +375,23 @@ trait ShimSparkErrorConverter {
         val filePath = params.get("filePath").map(_.toString).getOrElse("")
         Some(QueryExecutionErrors.cannotReadFilesError(dupCause, filePath))
 
+      case "ParquetFieldRequestedMoreThanOnce" =>
+        // Mirror Spark's 
`ParquetReadSupport.checkNoFieldRequestedMoreThanOnce` (SPARK-60262).
+        // The native reader raises this only for a Spark that has it, but
+        // `QueryExecutionErrors.parquetFieldRequestedMoreThanOnceError` is 
not on the Spark
+        // versions Comet compiles against, so build the same 
SparkRuntimeException from its
+        // error class. Wrap it in FAILED_READ_FILE.NO_HINT like the other 
Parquet read errors
+        // here, as Spark's file scan does at the task boundary. The 
SparkRuntimeException stays
+        // as `getCause`.
+        val requestedCause = new SparkRuntimeException(
+          errorClass = "PARQUET_FIELD_REQUESTED_MORE_THAN_ONCE",
+          messageParameters = Map(
+            "requestedFields" -> params("requestedFields").toString,
+            "parquetField" -> params("parquetField").toString,
+            "fieldIdReadConf" -> ("\"" + 
SQLConf.PARQUET_FIELD_ID_READ_ENABLED.key + "\"")))
+        val requestedPath = 
params.get("filePath").map(_.toString).getOrElse("")

Review Comment:
   Good catch, thanks. The native error carried no path, so the shim wrapped it 
with an empty one. Fixed in 201b71f1e.
   
   `ParquetFieldRequestedMoreThanOnce` now has a `file_path`, which goes out as 
the `filePath` parameter that `ShimSparkErrorConverter` already reads. The 
schema adapter that finds the conflict knows no file and leaves it empty. The 
footer check, which runs for every file when the flag is on, fills it in with 
the path Spark knows the file by (`spark_file_path`, which `FileContext` now 
shares), so the error names the file whichever file of the scan fails.
   
   Tests: the footer check test in `eager_page_index_reader_factory.rs` names 
the file, by the Spark path when the scan kept it and by the object-store 
location otherwise, and leaves a file without a conflict alone. In 
`CometNativeReaderSuite`, "Parquet field claims - the error names the file that 
holds the conflict" reads two files, one with the conflict, and checks that the 
`FAILED_READ_FILE` error names it, as Spark's does. It is skipped on a Spark 
that does not fail the read.
   
   I ran `CometNativeReaderSuite` on Spark 4.1.4, where the flag is on: 185 of 
185 pass, including the new test. On 4.1.3, where it is off, 184 pass and the 
new test is skipped.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to