From 57eff755038e23c5be23c39e3965102c7f59db7c Mon Sep 17 00:00:00 2001 From: nk1506 Date: Thu, 28 Mar 2024 10:39:56 +0530 Subject: [PATCH] Addressed comments --- .../apache/iceberg/hive/HiveViewOperations.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java index 319ce692a0fb..951b8ccbabf4 100644 --- a/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java +++ b/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java @@ -120,7 +120,7 @@ public void doCommit(ViewMetadata base, ViewMetadata metadata) { boolean hiveEngineEnabled = false; CommitStatus commitStatus = CommitStatus.FAILURE; - boolean updateHiveTable = false; + boolean updateHiveView = false; HiveLock lock = lockObject(); try { @@ -134,10 +134,16 @@ public void doCommit(ViewMetadata base, ViewMetadata metadata) { if (newView && tbl.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP) != null) { - throw new AlreadyExistsException("View already exists: %s.%s", database, viewName); + throw new AlreadyExistsException( + "%s already exists: %s.%s", + tbl.getTableType().equalsIgnoreCase(TableType.VIRTUAL_VIEW.name()) + ? ContentType.VIEW.value() + : ContentType.TABLE.value(), + database, + viewName); } - updateHiveTable = true; + updateHiveView = true; LOG.debug("Committing existing view: {}", fullName); } else { tbl = @@ -178,7 +184,7 @@ public void doCommit(ViewMetadata base, ViewMetadata metadata) { lock.ensureActive(); try { - persistTable(tbl, updateHiveTable, hiveLockEnabled(conf) ? null : baseMetadataLocation); + persistTable(tbl, updateHiveView, hiveLockEnabled(conf) ? null : baseMetadataLocation); lock.ensureActive(); commitStatus = CommitStatus.SUCCESS; @@ -190,7 +196,7 @@ public void doCommit(ViewMetadata base, ViewMetadata metadata) { + "Please check the commit history. If you are running into this issue, try reducing " + "iceberg.hive.lock-heartbeat-interval-ms.", le); - } catch (AlreadyExistsException e) { + } catch (org.apache.hadoop.hive.metastore.api.AlreadyExistsException e) { throw new AlreadyExistsException(e, "View already exists: %s.%s", database, viewName); } catch (InvalidObjectException e) {