Skip to content
Open
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
11 changes: 6 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8134,6 +8134,12 @@
},
"sqlState" : "42601"
},
"TABLES_OR_VIEWS_NOT_IN_SAME_DATABASE" : {
"message" : [
"Cannot retrieve tables or views that do not belong to the same database. Requested: <qualifiedTableNames>."
],
"sqlState" : "0A000"
},
"TABLE_LOCATION_URI_NOT_SPECIFIED" : {
"message" : [
"Table <identifier> did not specify locationUri."
Expand Down Expand Up @@ -10309,11 +10315,6 @@
"Some existing schema fields (<nonExistentColumnNames>) are not present in the new schema. We don't support dropping columns yet."
]
},
"_LEGACY_ERROR_TEMP_1072" : {
"message" : [
"Only the tables/views belong to the same database can be retrieved. Querying tables/views are <qualifiedTableNames>."
]
},
"_LEGACY_ERROR_TEMP_1079" : {
"message" : [
"Resource Type '<resourceType>' is not supported."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ private[sql] object QueryCompilationErrors extends QueryErrorsBase with Compilat
def cannotRetrieveTableOrViewNotInSameDatabaseError(
qualifiedTableNames: Seq[QualifiedTableName]): Throwable = {
new AnalysisException(
errorClass = "_LEGACY_ERROR_TEMP_1072",
errorClass = "TABLES_OR_VIEWS_NOT_IN_SAME_DATABASE",
messageParameters = Map("qualifiedTableNames" -> qualifiedTableNames.toString()))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,20 +820,30 @@ abstract class SessionCatalogSuite extends AnalysisTest with Eventually {

test("get tables by name when tables belong to different databases") {
withBasicCatalog { catalog =>
intercept[AnalysisException](catalog.getTablesByName(
Seq(
TableIdentifier("tbl1", Some("db1")),
TableIdentifier("tbl2", Some("db2"))
)
))
checkError(
exception = intercept[AnalysisException](catalog.getTablesByName(
Seq(
TableIdentifier("tbl1", Some("db1")),
TableIdentifier("tbl2", Some("db2"))
)
)),
condition = "TABLES_OR_VIEWS_NOT_IN_SAME_DATABASE",
parameters = Map(
"qualifiedTableNames" ->
"List(spark_catalog.db1.tbl1, spark_catalog.db2.tbl2)"))
// Get table without explicitly specifying database
catalog.setCurrentDatabase("db2")
intercept[AnalysisException](catalog.getTablesByName(
Seq(
TableIdentifier("tbl1", Some("db1")),
TableIdentifier("tbl2")
)
))
checkError(
exception = intercept[AnalysisException](catalog.getTablesByName(
Seq(
TableIdentifier("tbl1", Some("db1")),
TableIdentifier("tbl2")
)
)),
condition = "TABLES_OR_VIEWS_NOT_IN_SAME_DATABASE",
parameters = Map(
"qualifiedTableNames" ->
"List(spark_catalog.db1.tbl1, spark_catalog.db2.tbl2)"))
}
}

Expand Down