You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by bl...@apache.org on 2019/05/16 20:42:38 UTC

[flink] branch master updated: [hotfix][hive] return early in alterTable() to improve readability

This is an automated email from the ASF dual-hosted git repository.

bli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new 04d3974  [hotfix][hive] return early in alterTable() to improve readability
04d3974 is described below

commit 04d397430f57a60b68e6b3ef0c842f843eb6b5ed
Author: bowen.li <bo...@gmail.com>
AuthorDate: Thu May 16 13:42:10 2019 -0700

    [hotfix][hive] return early in alterTable() to improve readability
---
 .../flink/table/catalog/hive/HiveCatalogBase.java  | 23 +++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogBase.java b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogBase.java
index 27ca7a1..031a61a 100644
--- a/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogBase.java
+++ b/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalogBase.java
@@ -317,19 +317,20 @@ public abstract class HiveCatalogBase implements Catalog {
 				if (!ignoreIfNotExists) {
 					throw new TableNotExistException(catalogName, tablePath);
 				}
-			} else {
-				// TODO: [FLINK-12452] alterTable() in all catalogs should ensure existing base table and the new one are of the same type
-				Table newTable = createHiveTable(tablePath, newCatalogTable);
-
-				// client.alter_table() requires a valid location
-				// thus, if new table doesn't have that, it reuses location of the old table
-				if (!newTable.getSd().isSetLocation()) {
-					Table oldTable = getHiveTable(tablePath);
-					newTable.getSd().setLocation(oldTable.getSd().getLocation());
-				}
+				return;
+			}
 
-				client.alter_table(tablePath.getDatabaseName(), tablePath.getObjectName(), newTable);
+			// TODO: [FLINK-12452] alterTable() in all catalogs should ensure existing base table and the new one are of the same type
+			Table newTable = createHiveTable(tablePath, newCatalogTable);
+
+			// client.alter_table() requires a valid location
+			// thus, if new table doesn't have that, it reuses location of the old table
+			if (!newTable.getSd().isSetLocation()) {
+				Table oldTable = getHiveTable(tablePath);
+				newTable.getSd().setLocation(oldTable.getSd().getLocation());
 			}
+
+			client.alter_table(tablePath.getDatabaseName(), tablePath.getObjectName(), newTable);
 		} catch (TException e) {
 			throw new CatalogException(
 				String.format("Failed to rename table %s", tablePath.getFullName()), e);