You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2018/02/07 17:26:29 UTC
hive git commit: HIVE-18641: Remove MCreationMetadata from MTable
class (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)
Repository: hive
Updated Branches:
refs/heads/master bf93128e7 -> 31207eded
HIVE-18641: Remove MCreationMetadata from MTable class (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/31207ede
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/31207ede
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/31207ede
Branch: refs/heads/master
Commit: 31207eded3f130d3e336965d66825bb25ca89c35
Parents: bf93128
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Tue Feb 6 11:49:48 2018 -0800
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Wed Feb 7 09:19:43 2018 -0800
----------------------------------------------------------------------
.../hadoop/hive/metastore/ObjectStore.java | 55 ++++++++++++++------
.../hadoop/hive/metastore/model/MTable.java | 19 +------
2 files changed, 41 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hive/blob/31207ede/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
index 6498fe5..d58ed67 100644
--- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java
@@ -1124,6 +1124,11 @@ public class ObjectStore implements RawStore, Configurable {
MTable mtbl = convertToMTable(tbl);
pm.makePersistent(mtbl);
+ if (tbl.getCreationMetadata() != null) {
+ MCreationMetadata mcm = convertToMCreationMetadata(tbl.getCreationMetadata());
+ pm.makePersistent(mcm);
+ }
+
PrincipalPrivilegeSet principalPrivs = tbl.getPrivileges();
List<Object> toPersistPrivObjs = new ArrayList<>();
if (principalPrivs != null) {
@@ -1234,11 +1239,9 @@ public class ObjectStore implements RawStore, Configurable {
preDropStorageDescriptor(tbl.getSd());
- if (tbl.getCreationMetadata() != null) {
- // Remove creation metadata
- MCreationMetadata mcm = tbl.getCreationMetadata();
- tbl.setCreationMetadata(null);
- pm.deletePersistent(mcm);
+ if (materializedView) {
+ dropCreationMetadata(
+ tbl.getDatabase().getName(), tbl.getTableName());
}
// then remove the table
@@ -1257,6 +1260,25 @@ public class ObjectStore implements RawStore, Configurable {
return success;
}
+ private boolean dropCreationMetadata(String dbName, String tableName) throws MetaException,
+ NoSuchObjectException, InvalidObjectException, InvalidInputException {
+ boolean success = false;
+ try {
+ openTransaction();
+ MCreationMetadata mcm = getCreationMetadata(dbName, tableName);
+ pm.retrieve(mcm);
+ if (mcm != null) {
+ pm.deletePersistentAll(mcm);
+ }
+ success = commitTransaction();
+ } finally {
+ if (!success) {
+ rollbackTransaction();
+ }
+ }
+ return success;
+ }
+
private List<MConstraint> listAllTableConstraintsWithOptionalConstraintName
(String dbName, String tableName, String constraintname) {
dbName = normalizeIdentifier(dbName);
@@ -1309,6 +1331,11 @@ public class ObjectStore implements RawStore, Configurable {
try {
openTransaction();
tbl = convertToTable(getMTable(dbName, tableName));
+ // Retrieve creation metadata if needed
+ if (tbl != null && TableType.MATERIALIZED_VIEW.toString().equals(tbl.getTableType())) {
+ tbl.setCreationMetadata(
+ convertToCreationMetadata(getCreationMetadata(dbName, tableName)));
+ }
commited = commitTransaction();
} finally {
if (!commited) {
@@ -1557,11 +1584,6 @@ public class ObjectStore implements RawStore, Configurable {
pm.retrieveAll(mtbl.getSd().getCD());
nmtbl.mcd = mtbl.getSd().getCD();
}
- // Retrieve creation metadata if needed
- if (mtbl != null &&
- TableType.MATERIALIZED_VIEW.toString().equals(mtbl.getTableType())) {
- mtbl.setCreationMetadata(getCreationMetadata(db, table));
- }
commited = commitTransaction();
} finally {
rollbackAndCleanup(commited, query);
@@ -1665,7 +1687,6 @@ public class ObjectStore implements RawStore, Configurable {
.getRetention(), convertToStorageDescriptor(mtbl.getSd()),
convertToFieldSchemas(mtbl.getPartitionKeys()), convertMap(mtbl.getParameters()),
mtbl.getViewOriginalText(), mtbl.getViewExpandedText(), tableType);
- t.setCreationMetadata(convertToCreationMetadata(mtbl.getCreationMetadata()));
t.setRewriteEnabled(mtbl.isRewriteEnabled());
return t;
}
@@ -1705,7 +1726,7 @@ public class ObjectStore implements RawStore, Configurable {
.getCreateTime(), tbl.getLastAccessTime(), tbl.getRetention(),
convertToMFieldSchemas(tbl.getPartitionKeys()), tbl.getParameters(),
tbl.getViewOriginalText(), tbl.getViewExpandedText(), tbl.isRewriteEnabled(),
- convertToMCreationMetadata(tbl.getCreationMetadata()), tableType);
+ tableType);
}
private List<MFieldSchema> convertToMFieldSchemas(List<FieldSchema> keys) {
@@ -3717,10 +3738,14 @@ public class ObjectStore implements RawStore, Configurable {
oldt.setViewOriginalText(newt.getViewOriginalText());
oldt.setViewExpandedText(newt.getViewExpandedText());
oldt.setRewriteEnabled(newt.isRewriteEnabled());
- registerCreationSignature = newt.getCreationMetadata() != null;
+ registerCreationSignature = newTable.getCreationMetadata() != null;
if (registerCreationSignature) {
- oldt.getCreationMetadata().setTables(newt.getCreationMetadata().getTables());
- oldt.getCreationMetadata().setTxnList(newt.getCreationMetadata().getTxnList());
+ // Update creation metadata
+ MCreationMetadata newMcm = convertToMCreationMetadata(
+ newTable.getCreationMetadata());
+ MCreationMetadata mcm = getCreationMetadata(dbname, name);
+ mcm.setTables(newMcm.getTables());
+ mcm.setTxnList(newMcm.getTxnList());
}
// commit the changes
http://git-wip-us.apache.org/repos/asf/hive/blob/31207ede/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/model/MTable.java
----------------------------------------------------------------------
diff --git a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/model/MTable.java b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/model/MTable.java
index aea16ad..a38a125 100644
--- a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/model/MTable.java
+++ b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/model/MTable.java
@@ -35,7 +35,6 @@ public class MTable {
private String viewOriginalText;
private String viewExpandedText;
private boolean rewriteEnabled;
- private MCreationMetadata creationMetadata;
private String tableType;
public MTable() {}
@@ -57,8 +56,7 @@ public class MTable {
public MTable(String tableName, MDatabase database, MStorageDescriptor sd, String owner,
int createTime, int lastAccessTime, int retention, List<MFieldSchema> partitionKeys,
Map<String, String> parameters, String viewOriginalText, String viewExpandedText,
- boolean rewriteEnabled, MCreationMetadata creationMetadata,
- String tableType) {
+ boolean rewriteEnabled, String tableType) {
this.tableName = tableName;
this.database = database;
this.sd = sd;
@@ -71,7 +69,6 @@ public class MTable {
this.viewOriginalText = viewOriginalText;
this.viewExpandedText = viewExpandedText;
this.rewriteEnabled = rewriteEnabled;
- this.creationMetadata = creationMetadata;
this.tableType = tableType;
}
@@ -174,20 +171,6 @@ public class MTable {
}
/**
- * @return the metadata information related to a materialized view creation
- */
- public MCreationMetadata getCreationMetadata() {
- return creationMetadata;
- }
-
- /**
- * @param creationMetadata the metadata information to set
- */
- public void setCreationMetadata(MCreationMetadata creationMetadata) {
- this.creationMetadata = creationMetadata;
- }
-
- /**
* @return the owner
*/
public String getOwner() {