This is an automated email from the ASF dual-hosted git repository.
maxgekk pushed a commit to branch branch-3.4
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.4 by this push:
new 5e92386ba21 [SPARK-42313][SQL] Assign name to `_LEGACY_ERROR_TEMP_1152`
5e92386ba21 is described below
commit 5e92386ba21386611ebc1edc05350e80c0bb6aa7
Author: itholic <[email protected]>
AuthorDate: Mon Feb 13 16:06:09 2023 +0500
[SPARK-42313][SQL] Assign name to `_LEGACY_ERROR_TEMP_1152`
### What changes were proposed in this pull request?
This PR proposes to integrate _LEGACY_ERROR_TEMP_1152,
"PATH_ALREADY_EXISTS".
### Why are the changes needed?
We should assign proper name to _LEGACY_ERROR_TEMP_*
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
`./build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite*`
Closes #39953 from itholic/LEGACY_1152.
Lead-authored-by: itholic <[email protected]>
Co-authored-by: Haejoon Lee <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
(cherry picked from commit 39dbcd7edd3edc9ef68c41d8190e2e9e74f4cedd)
Signed-off-by: Max Gekk <[email protected]>
---
R/pkg/tests/fulltests/test_sparkSQL.R | 10 +++----
core/src/main/resources/error/error-classes.json | 11 ++++----
.../spark/sql/errors/QueryCompilationErrors.scala | 2 +-
.../spark/sql/sources/HadoopFsRelationTest.scala | 31 +++++++++++++++-------
4 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/R/pkg/tests/fulltests/test_sparkSQL.R
b/R/pkg/tests/fulltests/test_sparkSQL.R
index bec184750e9..b0c56f1c15d 100644
--- a/R/pkg/tests/fulltests/test_sparkSQL.R
+++ b/R/pkg/tests/fulltests/test_sparkSQL.R
@@ -622,7 +622,7 @@ test_that("read/write json files", {
# Test errorifexists
expect_error(write.df(df, jsonPath2, "json", mode = "errorifexists"),
- "analysis error - Path file:.*already exists")
+ "Error in save : analysis error -
\\[PATH_ALREADY_EXISTS\\].*")
# Test write.json
jsonPath3 <- tempfile(pattern = "jsonPath3", fileext = ".json")
@@ -3990,13 +3990,13 @@ test_that("Call DataFrameWriter.save() API in Java
without path and check argume
paste("Error in save :
org.apache.spark.SparkIllegalArgumentException:",
"Expected exactly one path to be specified"))
expect_error(write.json(df, jsonPath),
- "Error in json : analysis error - Path file:.*already exists")
+ "Error in json : analysis error - \\[PATH_ALREADY_EXISTS\\].*")
expect_error(write.text(df, jsonPath),
- "Error in text : analysis error - Path file:.*already exists")
+ "Error in text : analysis error - \\[PATH_ALREADY_EXISTS\\].*")
expect_error(write.orc(df, jsonPath),
- "Error in orc : analysis error - Path file:.*already exists")
+ "Error in orc : analysis error - \\[PATH_ALREADY_EXISTS\\].*")
expect_error(write.parquet(df, jsonPath),
- "Error in parquet : analysis error - Path file:.*already exists")
+ "Error in parquet : analysis error -
\\[PATH_ALREADY_EXISTS\\].*")
expect_error(write.parquet(df, jsonPath, mode = 123), "mode should be
character or omitted.")
# Arguments checking in R side.
diff --git a/core/src/main/resources/error/error-classes.json
b/core/src/main/resources/error/error-classes.json
index 33f31a97acf..86bde20b7fa 100644
--- a/core/src/main/resources/error/error-classes.json
+++ b/core/src/main/resources/error/error-classes.json
@@ -1224,6 +1224,12 @@
],
"sqlState" : "428FT"
},
+ "PATH_ALREADY_EXISTS" : {
+ "message" : [
+ "Path <outputPath> already exists. Set mode as \"overwrite\" to
overwrite the existing path."
+ ],
+ "sqlState" : "42K04"
+ },
"PATH_NOT_FOUND" : {
"message" : [
"Path does not exist: <path>."
@@ -2765,11 +2771,6 @@
"Fail to resolve data source for the table <table> since the table serde
property has the duplicated key <key> with extra options specified for this
scan operation. To fix this, you can rollback to the legacy behavior of
ignoring the extra options by setting the config <config> to `false`, or
address the conflicts of the same config."
]
},
- "_LEGACY_ERROR_TEMP_1152" : {
- "message" : [
- "Path <outputPath> already exists."
- ]
- },
"_LEGACY_ERROR_TEMP_1153" : {
"message" : [
"Cannot use <field> for partition column."
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
index 74dd5879061..fbcffe04d32 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryCompilationErrors.scala
@@ -1566,7 +1566,7 @@ private[sql] object QueryCompilationErrors extends
QueryErrorsBase {
def outputPathAlreadyExistsError(outputPath: Path): Throwable = {
new AnalysisException(
- errorClass = "_LEGACY_ERROR_TEMP_1152",
+ errorClass = "PATH_ALREADY_EXISTS",
messageParameters = Map("outputPath" -> outputPath.toString))
}
diff --git
a/sql/hive/src/test/scala/org/apache/spark/sql/sources/HadoopFsRelationTest.scala
b/sql/hive/src/test/scala/org/apache/spark/sql/sources/HadoopFsRelationTest.scala
index b7f06d3dcc3..c6e5585f619 100644
---
a/sql/hive/src/test/scala/org/apache/spark/sql/sources/HadoopFsRelationTest.scala
+++
b/sql/hive/src/test/scala/org/apache/spark/sql/sources/HadoopFsRelationTest.scala
@@ -240,9 +240,15 @@ abstract class HadoopFsRelationTest extends QueryTest with
SQLTestUtils with Tes
test("save()/load() - non-partitioned table - ErrorIfExists") {
withTempDir { file =>
- intercept[AnalysisException] {
-
testDF.write.format(dataSourceName).mode(SaveMode.ErrorIfExists).save(file.getCanonicalPath)
- }
+ checkError(
+ exception = intercept[AnalysisException] {
+ testDF.write.format(dataSourceName)
+ .mode(SaveMode.ErrorIfExists).save(file.getCanonicalPath)
+ },
+ errorClass = "PATH_ALREADY_EXISTS",
+ parameters = Map("outputPath" -> "file:.*"),
+ matchPVals = true
+ )
}
}
@@ -339,13 +345,18 @@ abstract class HadoopFsRelationTest extends QueryTest
with SQLTestUtils with Tes
test("save()/load() - partitioned table - ErrorIfExists") {
withTempDir { file =>
- intercept[AnalysisException] {
- partitionedTestDF.write
- .format(dataSourceName)
- .mode(SaveMode.ErrorIfExists)
- .partitionBy("p1", "p2")
- .save(file.getCanonicalPath)
- }
+ checkError(
+ exception = intercept[AnalysisException] {
+ partitionedTestDF.write
+ .format(dataSourceName)
+ .mode(SaveMode.ErrorIfExists)
+ .partitionBy("p1", "p2")
+ .save(file.getCanonicalPath)
+ },
+ errorClass = "PATH_ALREADY_EXISTS",
+ parameters = Map("outputPath" -> "file:.*"),
+ matchPVals = true
+ )
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]