Skip to content
Closed
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 @@ -656,6 +656,11 @@
],
"sqlState" : "42000"
},
"INVALID_EMPTY_LOCATION" : {
"message" : [
"The location name cannot be empty string, but `<location>` was given."
]
},
"INVALID_FIELD_NAME" : {
"message" : [
"Field name <fieldName> is invalid: <path> is not a struct."
Expand Down Expand Up @@ -1161,11 +1166,6 @@
}
}
},
"UNSUPPORTED_EMPTY_LOCATION" : {
"message" : [
"Unsupported empty location."
]
},
"UNSUPPORTED_FEATURE" : {
"message" : [
"The feature is not supported:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2799,10 +2799,10 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase {
"size" -> elementSize.toString))
}

def unsupportedEmptyLocationError(): SparkIllegalArgumentException = {
def invalidEmptyLocationError(location: String): SparkIllegalArgumentException = {
new SparkIllegalArgumentException(
errorClass = "UNSUPPORTED_EMPTY_LOCATION",
messageParameters = Map.empty)
errorClass = "INVALID_EMPTY_LOCATION",
messageParameters = Map("location" -> location))
}

def malformedProtobufMessageDetectedInMessageParsingError(e: Throwable): Throwable = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.get)
}
CreateDatabaseCommand(name, c.ifNotExists, location, comment, newProperties)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.get)
}
val finalProperties = properties.get(SupportsNamespaces.PROP_LOCATION).map { loc =>
properties + (SupportsNamespaces.PROP_LOCATION -> makeQualifiedDBObjectPath(loc))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ trait AlterNamespaceSetLocationSuiteBase extends QueryTest with DDLCommandTestUt
exception = intercept[SparkIllegalArgumentException] {
sql(sqlText)
},
errorClass = "UNSUPPORTED_EMPTY_LOCATION",
parameters = Map.empty)
errorClass = "INVALID_EMPTY_LOCATION",
parameters = Map("location" -> ""))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ trait CreateNamespaceSuiteBase extends QueryTest with DDLCommandTestUtils {
exception = intercept[SparkIllegalArgumentException] {
sql(sqlText)
},
errorClass = "UNSUPPORTED_EMPTY_LOCATION",
parameters = Map.empty)
errorClass = "INVALID_EMPTY_LOCATION",
parameters = Map("location" -> ""))
val uri = new Path(path).toUri
sql(s"CREATE NAMESPACE $ns LOCATION '$uri'")
// Make sure the location is qualified.
Expand Down