Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/src/main/resources/error/error-classes.json
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@
],
"sqlState" : "42000"
},
"PATH_NOT_FOUND" : {
"message" : [
"Path does not exist: <path>."
]
},
"PIVOT_VALUE_DATA_TYPE_MISMATCH" : {
"message" : [
"Invalid pivot value '<value>': value data type <valueType> does not match pivot column data type <pivotType>"
Expand Down Expand Up @@ -2221,11 +2226,6 @@
"Unable to infer schema for <format>. It must be specified manually."
]
},
"_LEGACY_ERROR_TEMP_1130" : {
"message" : [
"Path does not exist: <path>."
]
},
"_LEGACY_ERROR_TEMP_1131" : {
"message" : [
"Data source <className> does not support <outputMode> output mode."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1388,7 +1388,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase {

def dataPathNotExistError(path: String): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1130",
errorClass = "PATH_NOT_FOUND",
messageParameters = Map("path" -> path))
}

Expand Down
24 changes: 15 additions & 9 deletions sql/core/src/test/scala/org/apache/spark/sql/DataFrameSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ class DataFrameSuite extends QueryTest
new File(uuid, "file3").getAbsolutePath,
uuid).rdd
}
assert(e.getMessage.startsWith("Path does not exist"))
assert(e.getErrorClass == "PATH_NOT_FOUND")
} finally {

}
Expand All @@ -2341,20 +2341,26 @@ class DataFrameSuite extends QueryTest
// Non-existent initial path component:
val nonExistentBasePath = "/" + UUID.randomUUID().toString
assert(!new File(nonExistentBasePath).exists())
val e = intercept[AnalysisException] {
spark.read.format("text").load(s"$nonExistentBasePath/*")
}
assert(e.getMessage.startsWith("Path does not exist"))
checkError(
exception = intercept[AnalysisException] {
spark.read.format("text").load(s"$nonExistentBasePath/*")
},
errorClass = "PATH_NOT_FOUND",
parameters = Map("path" -> s"file:$nonExistentBasePath/*")
)

// Existent initial path component, but no matching files:
val baseDir = Utils.createTempDir()
val childDir = Utils.createTempDir(baseDir.getAbsolutePath)
assert(childDir.exists())
try {
val e1 = intercept[AnalysisException] {
spark.read.json(s"${baseDir.getAbsolutePath}/*/*-xyz.json").rdd
}
assert(e1.getMessage.startsWith("Path does not exist"))
checkError(
exception = intercept[AnalysisException] {
spark.read.json(s"${baseDir.getAbsolutePath}/*/*-xyz.json").rdd
},
errorClass = "PATH_NOT_FOUND",
parameters = Map("path" -> s"file:${baseDir.getAbsolutePath}/*/*-xyz.json")
)
} finally {
Utils.deleteRecursively(baseDir)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,22 @@ class DataSourceSuite extends SharedSparkSession with PrivateMethodTester {
}

test("test non existent paths") {
assertThrows[AnalysisException](
DataSource.checkAndGlobPathIfNecessary(
Seq(
path1.toString,
path2.toString,
nonExistentPath.toString
),
hadoopConf,
checkEmptyGlobPath = true,
checkFilesExist = true,
enableGlobbing = true
)
checkError(
exception = intercept[AnalysisException](
DataSource.checkAndGlobPathIfNecessary(
Seq(
path1.toString,
path2.toString,
nonExistentPath.toString
),
hadoopConf,
checkEmptyGlobPath = true,
checkFilesExist = true,
enableGlobbing = true
)
),
errorClass = "PATH_NOT_FOUND",
parameters = Map("path" -> nonExistentPath.toString)
)
}

Expand Down