From a0de4b89413fce59c89379645f9085d1e04a997b Mon Sep 17 00:00:00 2001 From: chenliang Date: Sat, 14 Dec 2019 14:40:31 +0800 Subject: [PATCH] shouldn't reset table owner when alter table --- .../org/apache/spark/sql/hive/client/HiveClientImpl.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala b/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala index 02c1ed93eb2f..65372fa57dad 100644 --- a/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala +++ b/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala @@ -937,7 +937,12 @@ private[hive] object HiveClientImpl { } hiveTable.setFields(schema.asJava) hiveTable.setPartCols(partCols.asJava) - userName.foreach(hiveTable.setOwner) + // Here when the table owner exists, we should not reset the owner with current userName + if (table.owner != null && table.owner.nonEmpty) { + hiveTable.setOwner(table.owner) + } else { + userName.foreach(hiveTable.setOwner) + } hiveTable.setCreateTime((table.createTime / 1000).toInt) hiveTable.setLastAccessTime((table.lastAccessTime / 1000).toInt) table.storage.locationUri.map(CatalogUtils.URIToString).foreach { loc =>