Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ case class LoadDataCommand(
uri
} else {
val uri = new URI(path)
if (uri.getScheme() != null && uri.getAuthority() != null) {
val hdfsUri = if (uri.getScheme() != null && uri.getAuthority() != null) {
uri
} else {
// Follow Hive's behavior:
Expand Down Expand Up @@ -380,6 +380,13 @@ case class LoadDataCommand(
}
new URI(scheme, authority, absolutePath, uri.getQuery(), uri.getFragment())
}
val hadoopConf = sparkSession.sessionState.newHadoopConf()
val srcPath = new Path(hdfsUri)
val fs = srcPath.getFileSystem(hadoopConf)
if (!fs.exists(srcPath)) {
throw new AnalysisException(s"LOAD DATA input path does not exist: $path")
}
hdfsUri
}

if (partition.nonEmpty) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2141,4 +2141,13 @@ class HiveDDLSuite
}
}
}

test("load command for non local invalid path validation") {
withTable("tbl") {
sql("CREATE TABLE tbl(i INT, j STRING)")
val e = intercept[AnalysisException](
sql("load data inpath '/doesnotexist.csv' into table tbl"))
assert(e.message.contains("LOAD DATA input path does not exist"))
}
}
}