From ee1829ae9f6efb8de7494cfcb38ecafcb08d5f66 Mon Sep 17 00:00:00 2001 From: itholic Date: Mon, 14 Nov 2022 16:51:48 +0900 Subject: [PATCH 01/10] [SPARK-41135][SQL] Rename UNSUPPORTED_EMPTY_LOCATION to INVALID_EMPTY_LOCATION --- core/src/main/resources/error/error-classes.json | 10 +++++----- .../apache/spark/sql/errors/QueryExecutionErrors.scala | 2 +- .../command/AlterNamespaceSetLocationSuiteBase.scala | 2 +- .../execution/command/CreateNamespaceSuiteBase.scala | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index 7f43cc2deda5b..0760fc5274720 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -616,6 +616,11 @@ ], "sqlState" : "42000" }, + "INVALID_EMPTY_LOCATION" : { + "message" : [ + "A specified location cannot be empty." + ] + }, "INVALID_FIELD_NAME" : { "message" : [ "Field name is invalid: is not a struct." @@ -1105,11 +1110,6 @@ } } }, - "UNSUPPORTED_EMPTY_LOCATION" : { - "message" : [ - "Unsupported empty location." - ] - }, "UNSUPPORTED_FEATURE" : { "message" : [ "The feature is not supported:" diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala index 828f52fe71d07..bd51850319c84 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala @@ -2801,7 +2801,7 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase { def unsupportedEmptyLocationError(): SparkIllegalArgumentException = { new SparkIllegalArgumentException( - errorClass = "UNSUPPORTED_EMPTY_LOCATION", + errorClass = "INVALID_EMPTY_LOCATION", messageParameters = Map.empty) } diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala index 653a6d918918b..0464fc4e9d221 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala @@ -51,7 +51,7 @@ trait AlterNamespaceSetLocationSuiteBase extends QueryTest with DDLCommandTestUt exception = intercept[SparkIllegalArgumentException] { sql(sqlText) }, - errorClass = "UNSUPPORTED_EMPTY_LOCATION", + errorClass = "INVALID_EMPTY_LOCATION", parameters = Map.empty) } } diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala index 1f0c3513dc936..8aecd72dc95d9 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala @@ -74,7 +74,7 @@ trait CreateNamespaceSuiteBase extends QueryTest with DDLCommandTestUtils { exception = intercept[SparkIllegalArgumentException] { sql(sqlText) }, - errorClass = "UNSUPPORTED_EMPTY_LOCATION", + errorClass = "INVALID_EMPTY_LOCATION", parameters = Map.empty) val uri = new Path(path).toUri sql(s"CREATE NAMESPACE $ns LOCATION '$uri'") From d32a32fdc91c6b55545c42328506dd63a55d9101 Mon Sep 17 00:00:00 2001 From: itholic Date: Mon, 14 Nov 2022 21:23:20 +0900 Subject: [PATCH 02/10] resolved the comments --- core/src/main/resources/error/error-classes.json | 2 +- .../org/apache/spark/sql/errors/QueryExecutionErrors.scala | 4 ++-- .../spark/sql/catalyst/analysis/ResolveSessionCatalog.scala | 4 ++-- .../sql/execution/datasources/v2/DataSourceV2Strategy.scala | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index 0760fc5274720..7ebc3295b416c 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -618,7 +618,7 @@ }, "INVALID_EMPTY_LOCATION" : { "message" : [ - "A specified location cannot be empty." + "The location name cannot be empty string or null, but `` given." ] }, "INVALID_FIELD_NAME" : { diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala index bd51850319c84..c68d252f61751 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala @@ -2799,10 +2799,10 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase { "size" -> elementSize.toString)) } - def unsupportedEmptyLocationError(): SparkIllegalArgumentException = { + def invalidEmptyLocationError(location: String): SparkIllegalArgumentException = { new SparkIllegalArgumentException( errorClass = "INVALID_EMPTY_LOCATION", - messageParameters = Map.empty) + messageParameters = Map("location" -> location)) } def malformedProtobufMessageDetectedInMessageParsingError(e: Throwable): Throwable = { diff --git a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala index d00d07150b0be..a4b0a24cf7acb 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala @@ -134,7 +134,7 @@ class ResolveSessionCatalog(val catalogManager: CatalogManager) case SetNamespaceLocation(DatabaseInSessionCatalog(db), location) if conf.useV1Command => if (StringUtils.isEmpty(location)) { - throw QueryExecutionErrors.unsupportedEmptyLocationError() + throw QueryExecutionErrors.invalidEmptyLocationError(location) } AlterDatabaseSetLocationCommand(db, location) @@ -243,7 +243,7 @@ class ResolveSessionCatalog(val catalogManager: CatalogManager) val location = c.properties.get(SupportsNamespaces.PROP_LOCATION) val newProperties = c.properties -- CatalogV2Util.NAMESPACE_RESERVED_PROPERTIES if (location.isDefined && location.get.isEmpty) { - throw QueryExecutionErrors.unsupportedEmptyLocationError() + throw QueryExecutionErrors.invalidEmptyLocationError(location) } CreateDatabaseCommand(name, c.ifNotExists, location, comment, newProperties) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala index 88dbe49c5af6b..ed1ae84b7f66a 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala @@ -353,7 +353,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat case SetNamespaceLocation(ResolvedNamespace(catalog, ns), location) => if (StringUtils.isEmpty(location)) { - throw QueryExecutionErrors.unsupportedEmptyLocationError() + throw QueryExecutionErrors.invalidEmptyLocationError(location) } AlterNamespaceSetPropertiesExec( catalog.asNamespaceCatalog, @@ -369,7 +369,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat case CreateNamespace(ResolvedNamespace(catalog, ns), ifNotExists, properties) => val location = properties.get(SupportsNamespaces.PROP_LOCATION) if (location.isDefined && location.get.isEmpty) { - throw QueryExecutionErrors.unsupportedEmptyLocationError() + throw QueryExecutionErrors.invalidEmptyLocationError(location) } val finalProperties = properties.get(SupportsNamespaces.PROP_LOCATION).map { loc => properties + (SupportsNamespaces.PROP_LOCATION -> makeQualifiedDBObjectPath(loc)) From deb074898fdf0a9874df106d167aaae5ab0affca Mon Sep 17 00:00:00 2001 From: itholic Date: Mon, 14 Nov 2022 21:26:43 +0900 Subject: [PATCH 03/10] fix --- core/src/main/resources/error/error-classes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index 7ebc3295b416c..d9431c06e994a 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -618,7 +618,7 @@ }, "INVALID_EMPTY_LOCATION" : { "message" : [ - "The location name cannot be empty string or null, but `` given." + "The location name cannot be empty string or null, but `` was given." ] }, "INVALID_FIELD_NAME" : { From 526cf80ed0fc665340ab31e7b119097a2a726e7e Mon Sep 17 00:00:00 2001 From: itholic Date: Tue, 15 Nov 2022 11:34:31 +0900 Subject: [PATCH 04/10] fix typing --- .../org/apache/spark/sql/errors/QueryExecutionErrors.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala index c68d252f61751..cdfcb44805e52 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala @@ -2799,10 +2799,10 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase { "size" -> elementSize.toString)) } - def invalidEmptyLocationError(location: String): SparkIllegalArgumentException = { + def invalidEmptyLocationError(location: Option[String]): SparkIllegalArgumentException = { new SparkIllegalArgumentException( errorClass = "INVALID_EMPTY_LOCATION", - messageParameters = Map("location" -> location)) + messageParameters = Map("location" -> location.toString)) } def malformedProtobufMessageDetectedInMessageParsingError(e: Throwable): Throwable = { From 43ed19b580d9b044caf417e8e4770112f39a76de Mon Sep 17 00:00:00 2001 From: itholic Date: Tue, 15 Nov 2022 15:21:39 +0900 Subject: [PATCH 05/10] Fix typing --- .../org/apache/spark/sql/errors/QueryExecutionErrors.scala | 2 +- .../spark/sql/catalyst/analysis/ResolveSessionCatalog.scala | 2 +- .../sql/execution/datasources/v2/DataSourceV2Strategy.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala index cdfcb44805e52..1d9a2a32f26d0 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala @@ -2799,7 +2799,7 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase { "size" -> elementSize.toString)) } - def invalidEmptyLocationError(location: Option[String]): SparkIllegalArgumentException = { + def invalidEmptyLocationError(location: String): SparkIllegalArgumentException = { new SparkIllegalArgumentException( errorClass = "INVALID_EMPTY_LOCATION", messageParameters = Map("location" -> location.toString)) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala index a4b0a24cf7acb..72e887ecd894b 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala @@ -243,7 +243,7 @@ class ResolveSessionCatalog(val catalogManager: CatalogManager) val location = c.properties.get(SupportsNamespaces.PROP_LOCATION) val newProperties = c.properties -- CatalogV2Util.NAMESPACE_RESERVED_PROPERTIES if (location.isDefined && location.get.isEmpty) { - throw QueryExecutionErrors.invalidEmptyLocationError(location) + throw QueryExecutionErrors.invalidEmptyLocationError(location.toString) } CreateDatabaseCommand(name, c.ifNotExists, location, comment, newProperties) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala index ed1ae84b7f66a..7e76245a0c23b 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala @@ -353,7 +353,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat case SetNamespaceLocation(ResolvedNamespace(catalog, ns), location) => if (StringUtils.isEmpty(location)) { - throw QueryExecutionErrors.invalidEmptyLocationError(location) + throw QueryExecutionErrors.invalidEmptyLocationError(location.toString) } AlterNamespaceSetPropertiesExec( catalog.asNamespaceCatalog, From 9a2b8e325980eced13a7471d54fcca48ddfceaaf Mon Sep 17 00:00:00 2001 From: itholic Date: Tue, 15 Nov 2022 15:24:21 +0900 Subject: [PATCH 06/10] fix type --- .../sql/execution/datasources/v2/DataSourceV2Strategy.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala index 7e76245a0c23b..9263e6660439f 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala @@ -353,7 +353,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat case SetNamespaceLocation(ResolvedNamespace(catalog, ns), location) => if (StringUtils.isEmpty(location)) { - throw QueryExecutionErrors.invalidEmptyLocationError(location.toString) + throw QueryExecutionErrors.invalidEmptyLocationError(location) } AlterNamespaceSetPropertiesExec( catalog.asNamespaceCatalog, @@ -369,7 +369,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat case CreateNamespace(ResolvedNamespace(catalog, ns), ifNotExists, properties) => val location = properties.get(SupportsNamespaces.PROP_LOCATION) if (location.isDefined && location.get.isEmpty) { - throw QueryExecutionErrors.invalidEmptyLocationError(location) + throw QueryExecutionErrors.invalidEmptyLocationError(location.toString) } val finalProperties = properties.get(SupportsNamespaces.PROP_LOCATION).map { loc => properties + (SupportsNamespaces.PROP_LOCATION -> makeQualifiedDBObjectPath(loc)) From d73c590ce37348a2f374f6b52fa033758112a638 Mon Sep 17 00:00:00 2001 From: itholic Date: Wed, 16 Nov 2022 16:07:59 +0900 Subject: [PATCH 07/10] fix test --- .../execution/command/AlterNamespaceSetLocationSuiteBase.scala | 2 +- .../spark/sql/execution/command/CreateNamespaceSuiteBase.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala index 0464fc4e9d221..5b78665d878ef 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/AlterNamespaceSetLocationSuiteBase.scala @@ -52,7 +52,7 @@ trait AlterNamespaceSetLocationSuiteBase extends QueryTest with DDLCommandTestUt sql(sqlText) }, errorClass = "INVALID_EMPTY_LOCATION", - parameters = Map.empty) + parameters = Map("location" -> "")) } } diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala index 8aecd72dc95d9..a3167a97b8501 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala @@ -75,7 +75,7 @@ trait CreateNamespaceSuiteBase extends QueryTest with DDLCommandTestUtils { sql(sqlText) }, errorClass = "INVALID_EMPTY_LOCATION", - parameters = Map.empty) + parameters = Map("location" -> "Some()")) val uri = new Path(path).toUri sql(s"CREATE NAMESPACE $ns LOCATION '$uri'") // Make sure the location is qualified. From d4d5b286123d38d8c27732948c730774b231f62b Mon Sep 17 00:00:00 2001 From: itholic Date: Thu, 17 Nov 2022 20:05:01 +0900 Subject: [PATCH 08/10] fix location --- .../sql/execution/datasources/v2/DataSourceV2Strategy.scala | 2 +- .../spark/sql/execution/command/CreateNamespaceSuiteBase.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala index 9263e6660439f..34dd1fb9c393f 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DataSourceV2Strategy.scala @@ -369,7 +369,7 @@ class DataSourceV2Strategy(session: SparkSession) extends Strategy with Predicat case CreateNamespace(ResolvedNamespace(catalog, ns), ifNotExists, properties) => val location = properties.get(SupportsNamespaces.PROP_LOCATION) if (location.isDefined && location.get.isEmpty) { - throw QueryExecutionErrors.invalidEmptyLocationError(location.toString) + throw QueryExecutionErrors.invalidEmptyLocationError(location.get) } val finalProperties = properties.get(SupportsNamespaces.PROP_LOCATION).map { loc => properties + (SupportsNamespaces.PROP_LOCATION -> makeQualifiedDBObjectPath(loc)) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala index a3167a97b8501..947bc4a133f0d 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala @@ -75,7 +75,7 @@ trait CreateNamespaceSuiteBase extends QueryTest with DDLCommandTestUtils { sql(sqlText) }, errorClass = "INVALID_EMPTY_LOCATION", - parameters = Map("location" -> "Some()")) + parameters = Map("location" -> "``")) val uri = new Path(path).toUri sql(s"CREATE NAMESPACE $ns LOCATION '$uri'") // Make sure the location is qualified. From 71e5c424f38f720bdd5fb0a75412bac99a2f5c1f Mon Sep 17 00:00:00 2001 From: itholic Date: Fri, 18 Nov 2022 11:24:29 +0900 Subject: [PATCH 09/10] fix test --- .../org/apache/spark/sql/errors/QueryExecutionErrors.scala | 2 +- .../spark/sql/catalyst/analysis/ResolveSessionCatalog.scala | 2 +- .../spark/sql/execution/command/CreateNamespaceSuiteBase.scala | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala index 1d9a2a32f26d0..c68d252f61751 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala @@ -2802,7 +2802,7 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase { def invalidEmptyLocationError(location: String): SparkIllegalArgumentException = { new SparkIllegalArgumentException( errorClass = "INVALID_EMPTY_LOCATION", - messageParameters = Map("location" -> location.toString)) + messageParameters = Map("location" -> location)) } def malformedProtobufMessageDetectedInMessageParsingError(e: Throwable): Throwable = { diff --git a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala index 72e887ecd894b..d7e26b04ce47e 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveSessionCatalog.scala @@ -243,7 +243,7 @@ class ResolveSessionCatalog(val catalogManager: CatalogManager) val location = c.properties.get(SupportsNamespaces.PROP_LOCATION) val newProperties = c.properties -- CatalogV2Util.NAMESPACE_RESERVED_PROPERTIES if (location.isDefined && location.get.isEmpty) { - throw QueryExecutionErrors.invalidEmptyLocationError(location.toString) + throw QueryExecutionErrors.invalidEmptyLocationError(location.get) } CreateDatabaseCommand(name, c.ifNotExists, location, comment, newProperties) diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala index 947bc4a133f0d..e90469c29a59f 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CreateNamespaceSuiteBase.scala @@ -75,7 +75,7 @@ trait CreateNamespaceSuiteBase extends QueryTest with DDLCommandTestUtils { sql(sqlText) }, errorClass = "INVALID_EMPTY_LOCATION", - parameters = Map("location" -> "``")) + parameters = Map("location" -> "")) val uri = new Path(path).toUri sql(s"CREATE NAMESPACE $ns LOCATION '$uri'") // Make sure the location is qualified. From d1056ce95925108b33881f38862c08cb6651da87 Mon Sep 17 00:00:00 2001 From: itholic Date: Tue, 22 Nov 2022 13:35:47 +0900 Subject: [PATCH 10/10] exclude `null` from the message --- core/src/main/resources/error/error-classes.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/error/error-classes.json b/core/src/main/resources/error/error-classes.json index d0ae99f233524..f8c599566bea6 100644 --- a/core/src/main/resources/error/error-classes.json +++ b/core/src/main/resources/error/error-classes.json @@ -658,7 +658,7 @@ }, "INVALID_EMPTY_LOCATION" : { "message" : [ - "The location name cannot be empty string or null, but `` was given." + "The location name cannot be empty string, but `` was given." ] }, "INVALID_FIELD_NAME" : {