Skip to content

Commit 5e15c6d

Browse files
itholicbeliefer
authored andcommitted
[SPARK-40948][SQL][FOLLOWUP] Restore PATH_NOT_FOUND
### What changes were proposed in this pull request? The original PR to introduce the error class `PATH_NOT_FOUND` was reverted since it breaks the tests in different test env. This PR proposes to restore it back. ### Why are the changes needed? Restoring the reverted changes with proper fix. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? The existing CI should pass. Closes apache#38575 from itholic/SPARK-40948-followup. Authored-by: itholic <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent d8eab12 commit 5e15c6d

File tree

5 files changed

+52
-39
lines changed

5 files changed

+52
-39
lines changed

R/pkg/tests/fulltests/test_sparkSQL.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3990,12 +3990,16 @@ test_that("Call DataFrameWriter.load() API in Java without path and check argume
39903990
expect_error(read.df(source = "json"),
39913991
paste("Error in load : analysis error - Unable to infer schema for JSON.",
39923992
"It must be specified manually"))
3993-
expect_error(read.df("arbitrary_path"), "Error in load : analysis error - Path does not exist")
3994-
expect_error(read.json("arbitrary_path"), "Error in json : analysis error - Path does not exist")
3995-
expect_error(read.text("arbitrary_path"), "Error in text : analysis error - Path does not exist")
3996-
expect_error(read.orc("arbitrary_path"), "Error in orc : analysis error - Path does not exist")
3993+
expect_error(read.df("arbitrary_path"),
3994+
"Error in load : analysis error - \\[PATH_NOT_FOUND\\].*")
3995+
expect_error(read.json("arbitrary_path"),
3996+
"Error in json : analysis error - \\[PATH_NOT_FOUND\\].*")
3997+
expect_error(read.text("arbitrary_path"),
3998+
"Error in text : analysis error - \\[PATH_NOT_FOUND\\].*")
3999+
expect_error(read.orc("arbitrary_path"),
4000+
"Error in orc : analysis error - \\[PATH_NOT_FOUND\\].*")
39974001
expect_error(read.parquet("arbitrary_path"),
3998-
"Error in parquet : analysis error - Path does not exist")
4002+
"Error in parquet : analysis error - \\[PATH_NOT_FOUND\\].*")
39994003

40004004
# Arguments checking in R side.
40014005
expect_error(read.df(path = c(3)),

core/src/main/resources/error/error-classes.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,11 @@
912912
],
913913
"sqlState" : "42000"
914914
},
915+
"PATH_NOT_FOUND" : {
916+
"message" : [
917+
"Path does not exist: <path>."
918+
]
919+
},
915920
"PIVOT_VALUE_DATA_TYPE_MISMATCH" : {
916921
"message" : [
917922
"Invalid pivot value '<value>': value data type <valueType> does not match pivot column data type <pivotType>"
@@ -2332,11 +2337,6 @@
23322337
"Unable to infer schema for <format>. It must be specified manually."
23332338
]
23342339
},
2335-
"_LEGACY_ERROR_TEMP_1130" : {
2336-
"message" : [
2337-
"Path does not exist: <path>."
2338-
]
2339-
},
23402340
"_LEGACY_ERROR_TEMP_1131" : {
23412341
"message" : [
23422342
"Data source <className> does not support <outputMode> output mode."

sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,7 +1378,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase {
13781378

13791379
def dataPathNotExistError(path: String): Throwable = {
13801380
new AnalysisException(
1381-
errorClass = "_LEGACY_ERROR_TEMP_1130",
1381+
errorClass = "PATH_NOT_FOUND",
13821382
messageParameters = Map("path" -> path))
13831383
}
13841384

sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2327,39 +2327,44 @@ class DataFrameSuite extends QueryTest
23272327
test("SPARK-13774: Check error message for non existent path without globbed paths") {
23282328
val uuid = UUID.randomUUID().toString
23292329
val baseDir = Utils.createTempDir()
2330-
try {
2331-
val e = intercept[AnalysisException] {
2330+
checkError(
2331+
exception = intercept[AnalysisException] {
23322332
spark.read.format("csv").load(
23332333
new File(baseDir, "file").getAbsolutePath,
23342334
new File(baseDir, "file2").getAbsolutePath,
23352335
new File(uuid, "file3").getAbsolutePath,
23362336
uuid).rdd
2337-
}
2338-
assert(e.getMessage.startsWith("Path does not exist"))
2339-
} finally {
2340-
2341-
}
2342-
2337+
},
2338+
errorClass = "PATH_NOT_FOUND",
2339+
parameters = Map("path" -> "file:.*"),
2340+
matchPVals = true
2341+
)
23432342
}
23442343

23452344
test("SPARK-13774: Check error message for not existent globbed paths") {
23462345
// Non-existent initial path component:
23472346
val nonExistentBasePath = "/" + UUID.randomUUID().toString
23482347
assert(!new File(nonExistentBasePath).exists())
2349-
val e = intercept[AnalysisException] {
2350-
spark.read.format("text").load(s"$nonExistentBasePath/*")
2351-
}
2352-
assert(e.getMessage.startsWith("Path does not exist"))
2348+
checkError(
2349+
exception = intercept[AnalysisException] {
2350+
spark.read.format("text").load(s"$nonExistentBasePath/*")
2351+
},
2352+
errorClass = "PATH_NOT_FOUND",
2353+
parameters = Map("path" -> s"file:$nonExistentBasePath/*")
2354+
)
23532355

23542356
// Existent initial path component, but no matching files:
23552357
val baseDir = Utils.createTempDir()
23562358
val childDir = Utils.createTempDir(baseDir.getAbsolutePath)
23572359
assert(childDir.exists())
23582360
try {
2359-
val e1 = intercept[AnalysisException] {
2360-
spark.read.json(s"${baseDir.getAbsolutePath}/*/*-xyz.json").rdd
2361-
}
2362-
assert(e1.getMessage.startsWith("Path does not exist"))
2361+
checkError(
2362+
exception = intercept[AnalysisException] {
2363+
spark.read.json(s"${baseDir.getAbsolutePath}/*/*-xyz.json").rdd
2364+
},
2365+
errorClass = "PATH_NOT_FOUND",
2366+
parameters = Map("path" -> s"file:${baseDir.getAbsolutePath}/*/*-xyz.json")
2367+
)
23632368
} finally {
23642369
Utils.deleteRecursively(baseDir)
23652370
}

sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/DataSourceSuite.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,22 @@ class DataSourceSuite extends SharedSparkSession with PrivateMethodTester {
109109
}
110110

111111
test("test non existent paths") {
112-
assertThrows[AnalysisException](
113-
DataSource.checkAndGlobPathIfNecessary(
114-
Seq(
115-
path1.toString,
116-
path2.toString,
117-
nonExistentPath.toString
118-
),
119-
hadoopConf,
120-
checkEmptyGlobPath = true,
121-
checkFilesExist = true,
122-
enableGlobbing = true
123-
)
112+
checkError(
113+
exception = intercept[AnalysisException](
114+
DataSource.checkAndGlobPathIfNecessary(
115+
Seq(
116+
path1.toString,
117+
path2.toString,
118+
nonExistentPath.toString
119+
),
120+
hadoopConf,
121+
checkEmptyGlobPath = true,
122+
checkFilesExist = true,
123+
enableGlobbing = true
124+
)
125+
),
126+
errorClass = "PATH_NOT_FOUND",
127+
parameters = Map("path" -> nonExistentPath.toString)
124128
)
125129
}
126130

0 commit comments

Comments
 (0)