diff --git a/spark/src/main/spark-4.0/org/apache/spark/sql/comet/shims/ShimSparkErrorConverter.scala b/spark/src/main/spark-4.0/org/apache/spark/sql/comet/shims/ShimSparkErrorConverter.scala index fc7d8277ed..46bdd2ec03 100644 --- a/spark/src/main/spark-4.0/org/apache/spark/sql/comet/shims/ShimSparkErrorConverter.scala +++ b/spark/src/main/spark-4.0/org/apache/spark/sql/comet/shims/ShimSparkErrorConverter.scala @@ -19,11 +19,12 @@ package org.apache.spark.sql.comet.shims +import java.io.FileNotFoundException + import scala.util.matching.Regex import org.apache.spark.QueryContext import org.apache.spark.SparkException -import org.apache.spark.SparkFileNotFoundException import org.apache.spark.sql.errors.QueryExecutionErrors import org.apache.spark.sql.types._ import org.apache.spark.unsafe.types.UTF8String @@ -292,17 +293,13 @@ trait ShimSparkErrorConverter { case "FileNotFound" => val msg = params("message").toString - // Extract file path from native error message and format like Hadoop's - // FileNotFoundException: "File does not exist" val path = ShimSparkErrorConverter.ObjectLocationPattern .findFirstMatchIn(msg) .map(_.group(1)) .getOrElse(msg) - // readCurrentFileNotFoundError was removed in Spark 4.0; construct directly Some( - new SparkFileNotFoundException( - errorClass = "_LEGACY_ERROR_TEMP_2055", - messageParameters = Map("message" -> s"File $path does not exist"))) + QueryExecutionErrors + .fileNotExistError(path, new FileNotFoundException(s"File $path does not exist"))) case _ => // Unknown error type - return None to trigger fallback