This is an automated email from the ASF dual-hosted git repository. lzljs3620320 pushed a commit to branch release-1.2 in repository https://gitbox.apache.org/repos/asf/paimon.git
commit 2aabf52d0f84187320d1482dd9118343587e698e Author: cxzl25 <[email protected]> AuthorDate: Thu Jun 12 15:39:45 2025 +0800 [hive] Hive catalog configuration to get owner for table creation (#5668) --- .../java/org/apache/paimon/hive/HiveCatalog.java | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java index e0f94d92da..35747cdb63 100644 --- a/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java +++ b/paimon-hive/paimon-hive-catalog/src/main/java/org/apache/paimon/hive/HiveCatalog.java @@ -74,6 +74,7 @@ import org.apache.hadoop.hive.metastore.api.StorageDescriptor; import org.apache.hadoop.hive.metastore.api.Table; import org.apache.hadoop.hive.metastore.api.UnknownTableException; import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants; +import org.apache.hadoop.security.UserGroupInformation; import org.apache.thrift.TException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -1358,6 +1359,22 @@ public class HiveCatalog extends AbstractCatalog { return table != null && TableType.EXTERNAL_TABLE.name().equals(table.getTableType()); } + private static String currentUser() { + String username = null; + try { + username = UserGroupInformation.getCurrentUser().getShortUserName(); + } catch (IOException e) { + LOG.warn("Failed to get Hadoop user", e); + } + + if (username != null) { + return username; + } else { + LOG.warn("Hadoop user is null, defaulting to user.name"); + return System.getProperty("user.name"); + } + } + private Table newHmsTable( Identifier identifier, Map<String, String> tableParameters, @@ -1368,8 +1385,7 @@ public class HiveCatalog extends AbstractCatalog { new Table( identifier.getTableName(), identifier.getDatabaseName(), - // current linux user - System.getProperty("user.name"), + currentUser(), (int) (currentTimeMillis / 1000), (int) (currentTimeMillis / 1000), Integer.MAX_VALUE,
