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 @@ -940,7 +940,7 @@ private[hive] object HiveClientImpl {
}
hiveTable.setFields(schema.asJava)
hiveTable.setPartCols(partCols.asJava)
userName.foreach(hiveTable.setOwner)
Option(table.owner).filter(_.nonEmpty).orElse(userName).foreach(hiveTable.setOwner)
hiveTable.setCreateTime((table.createTime / 1000).toInt)
hiveTable.setLastAccessTime((table.lastAccessTime / 1000).toInt)
table.storage.locationUri.map(CatalogUtils.URIToString).foreach { loc =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,19 @@ class HiveExternalCatalogSuite extends ExternalCatalogSuite {
catalog.createDatabase(newDb("dbWithNullDesc").copy(description = null), ignoreIfExists = false)
assert(catalog.getDatabase("dbWithNullDesc").description == "")
}

test("SPARK-29498 CatalogTable to HiveTable should not change the table's ownership") {
val catalog = newBasicCatalog()
val owner = "SPARK-29498"
val hiveTable = CatalogTable(
identifier = TableIdentifier("spark_29498", Some("db1")),
tableType = CatalogTableType.MANAGED,
storage = storageFormat,
owner = owner,
schema = new StructType().add("i", "int"),
provider = Some("hive"))

catalog.createTable(hiveTable, ignoreIfExists = false)
assert(catalog.getTable("db1", "spark_29498").owner === owner)
}
}