commit 8a2a7280de6c7c2e2c6fbb9c45595a8ebea929c7 Author: Janaki Lahorani Date: Wed Jul 19 16:40:40 2017 -0700 Fix for HIVE-16759. The notification message in JSON format now includes table type. diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AddPartitionMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AddPartitionMessage.java index 5b114b5b278eb2b78436cda7a9763c97bfae38f6..9dacbf6e87c9e8c124abcf5cee4100bb3af991f3 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AddPartitionMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AddPartitionMessage.java @@ -37,6 +37,8 @@ protected AddPartitionMessage() { */ public abstract String getTable(); + public abstract String getTableType(); + /** * Getter for list of partitions added. * @return List of maps, where each map identifies values for each partition-key, for every added partition. diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterPartitionMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterPartitionMessage.java index 10a300de42f77c27698e620b657307cdde739fa3..8d9575e7f2937bd49ec1ea793b42b24fb33dab35 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterPartitionMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterPartitionMessage.java @@ -31,6 +31,8 @@ protected AlterPartitionMessage() { public abstract String getTable(); + public abstract String getTableType(); + public abstract Map getKeyValues(); @Override diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterTableMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterTableMessage.java index 0b58f2993763468df1ea46141035ddcff9c32b53..94f07cd53f74fdb56bf503737d00cd71292eab50 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterTableMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/AlterTableMessage.java @@ -28,6 +28,7 @@ protected AlterTableMessage() { } public abstract String getTable(); + public abstract String getTableType(); @Override public HCatEventMessage checkValid() { diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/CreateTableMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/CreateTableMessage.java index 6c8e2a467288033214e353f3968535a680f100d6..6442340698b15ed88b5c105a50540000c3776961 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/CreateTableMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/CreateTableMessage.java @@ -34,6 +34,8 @@ protected CreateTableMessage() { */ public abstract String getTable(); + public abstract String getTableType(); + @Override public HCatEventMessage checkValid() { if (getTable() == null) diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropPartitionMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropPartitionMessage.java index ee222ec37905c72f8e6d43b72058fddf7fb2dae0..d7b74f7530e7628a3a13e36abbccce0790f59082 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropPartitionMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropPartitionMessage.java @@ -32,6 +32,7 @@ protected DropPartitionMessage() { } public abstract String getTable(); + public abstract String getTableType(); public abstract List> getPartitions (); @Override diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropTableMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropTableMessage.java index e47b5721ecf6ffd2c0fb3acd2faafed40db72d55..345345e341765c6ebfb5bda88c5f3616f1c73d92 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropTableMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/DropTableMessage.java @@ -33,6 +33,7 @@ protected DropTableMessage() { * @return Table-name (String). */ public abstract String getTable(); + public abstract String getTableType(); @Override public HCatEventMessage checkValid() { diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java index be7ea10d457f2e2f1c2e6bcc9c5ee98783afb398..d2aae7bcdfb1e78133cd9a23f8dc852c42a75ad9 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/InsertMessage.java @@ -36,6 +36,7 @@ protected InsertMessage() { * @return Table-name (String). */ public abstract String getTable(); + public abstract String getTableType(); /** * Get the map of partition keyvalues. Will be null if this insert is to a table and not a diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java index 44574feb0da1d34cbfc4f4eac629d7029fe8b37b..28026dbdf098a7f4fd918442c139011dbcb87347 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/MessageFactory.java @@ -211,4 +211,16 @@ public abstract AlterPartitionMessage buildAlterPartitionMessage(Table table, Pa */ public abstract InsertMessage buildInsertMessage(String db, String table, Map partVals, List files); + + /** + * Factory method for building insert message + * @param db Name of the database the insert occurred in + * @param table Table the insert occurred in + * @param partVals Partition values for the partition that the insert occurred in, may be null + * if the insert was done into a non-partitioned table + * @param files List of files created as a result of the insert, may be null. + * @return instance of InsertMessage + */ + public abstract InsertMessage buildInsertMessage(String db, Table table, + Map partVals, List files); } diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAddPartitionMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAddPartitionMessage.java index ac7dcd919495cbc2c7acb1f6f9dd6cd2538e71b6..5d201f465ff4b4b22d4e1838687d4a1e1c7e9cb3 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAddPartitionMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAddPartitionMessage.java @@ -31,7 +31,7 @@ public class JSONAddPartitionMessage extends AddPartitionMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -45,11 +45,17 @@ public JSONAddPartitionMessage() {} public JSONAddPartitionMessage(String server, String servicePrincipal, String db, String table, - List> partitions, Long timestamp) { + List> partitions, Long timestamp) { + this(server, servicePrincipal, db, table, null, partitions, timestamp); + } + + public JSONAddPartitionMessage(String server, String servicePrincipal, String db, String table, + String tableType, List> partitions, Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.partitions = partitions; this.timestamp = timestamp; checkValid(); @@ -68,6 +74,11 @@ public JSONAddPartitionMessage(String server, String servicePrincipal, String db public String getTable() { return table; } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public Long getTimestamp() { return timestamp; } @Override diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterPartitionMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterPartitionMessage.java index 4f1d10452635e50564ab8da70b11ea215e8a1000..7ae7d75168b0e9485992ee8a0285273a931567dd 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterPartitionMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterPartitionMessage.java @@ -34,7 +34,7 @@ public class JSONAlterPartitionMessage extends AlterPartitionMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -53,16 +53,26 @@ public JSONAlterPartitionMessage(String server, String table, Map keyValues, Long timestamp) { + this(server, servicePrincipal, db, table, null, keyValues, timestamp); + } + + public JSONAlterPartitionMessage(String server, + String servicePrincipal, + String db, + String table, + String tableType, + Map keyValues, + Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.timestamp = timestamp; this.keyValues = keyValues; checkValid(); } - @Override public String getServer() { return server; @@ -89,6 +99,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public Map getKeyValues() { return keyValues; } diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterTableMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterTableMessage.java index b057d4aa72d543fd48eb5e9da3dc7998c24267cf..f23aedf0b393d0c270596d4b9db968d6536f8a92 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterTableMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONAlterTableMessage.java @@ -32,7 +32,7 @@ public class JSONAlterTableMessage extends AlterTableMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -47,15 +47,24 @@ public JSONAlterTableMessage(String server, String db, String table, Long timestamp) { + this(server, servicePrincipal, db, table, null, timestamp); + } + + public JSONAlterTableMessage(String server, + String servicePrincipal, + String db, + String table, + String tableType, + Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.timestamp = timestamp; checkValid(); } - @Override public String getServer() { return server; @@ -82,6 +91,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public String toString() { try { return JSONMessageDeserializer.mapper.writeValueAsString(this); diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateTableMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateTableMessage.java index 9c667300e0049c19d946b25b36c9582ba5408c10..327dc972de71c4e441f1f87af9c7b47fc4654374 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateTableMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONCreateTableMessage.java @@ -28,7 +28,7 @@ public class JSONCreateTableMessage extends CreateTableMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -38,11 +38,18 @@ */ public JSONCreateTableMessage() {} - public JSONCreateTableMessage(String server, String servicePrincipal, String db, String table, Long timestamp) { + public JSONCreateTableMessage(String server, String servicePrincipal, String db, String table, + Long timestamp) { + this(server, servicePrincipal, db, table, null, timestamp); + } + + public JSONCreateTableMessage(String server, String servicePrincipal, String db, String table, + String tableType, Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.timestamp = timestamp; checkValid(); } @@ -63,6 +70,11 @@ public JSONCreateTableMessage(String server, String servicePrincipal, String db, public String getTable() { return table; } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public String toString() { try { return JSONMessageDeserializer.mapper.writeValueAsString(this); diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropPartitionMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropPartitionMessage.java index a4d6400924895ca309308a8da0c54780ba4915b8..ecdc39d05961b2c8cb2498236340226c1f66ea32 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropPartitionMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropPartitionMessage.java @@ -31,7 +31,7 @@ public class JSONDropPartitionMessage extends DropPartitionMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -45,11 +45,17 @@ public JSONDropPartitionMessage() {} public JSONDropPartitionMessage(String server, String servicePrincipal, String db, String table, - List> partitions, Long timestamp) { + List> partitions, Long timestamp) { + this(server, servicePrincipal, db, table, null, partitions, timestamp); + } + + public JSONDropPartitionMessage(String server, String servicePrincipal, String db, String table, + String tableType, List> partitions, Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.partitions = partitions; this.timestamp = timestamp; checkValid(); @@ -69,6 +75,11 @@ public JSONDropPartitionMessage(String server, String servicePrincipal, String d public String getTable() { return table; } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public Long getTimestamp() { return timestamp; } @Override diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropTableMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropTableMessage.java index 3b6202385e0f92aa35105605b549d9df4ed089dd..430062544bf118d8c996f274e14fd3435f2d3941 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropTableMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONDropTableMessage.java @@ -28,7 +28,7 @@ public class JSONDropTableMessage extends DropTableMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -38,11 +38,13 @@ */ public JSONDropTableMessage() {} - public JSONDropTableMessage(String server, String servicePrincipal, String db, String table, Long timestamp) { + public JSONDropTableMessage(String server, String servicePrincipal, String db, String table, + String tableType, Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.timestamp = timestamp; checkValid(); } @@ -52,6 +54,11 @@ public JSONDropTableMessage(String server, String servicePrincipal, String db, S public String getTable() { return table; } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public String getServer() { return server; } @Override diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java index 8a4db15149127687655b4609b9853ccb03039616..667df4dd43dbed5868bbcb431af8cb21fa48a9a7 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONInsertMessage.java @@ -31,7 +31,7 @@ public class JSONInsertMessage extends InsertMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -49,10 +49,17 @@ public JSONInsertMessage() {} public JSONInsertMessage(String server, String servicePrincipal, String db, String table, Map partKeyVals, List files, Long timestamp) { + this(server, servicePrincipal, db, table, null, partKeyVals, files, timestamp); + } + + public JSONInsertMessage(String server, String servicePrincipal, String db, String table, + String tableType, Map partKeyVals, List files, + Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.timestamp = timestamp; this.partKeyVals = partKeyVals; this.files = files; @@ -64,6 +71,11 @@ public JSONInsertMessage(String server, String servicePrincipal, String db, Stri public String getTable() { return table; } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public String getServer() { return server; } @Override diff --git hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java index 251084f99326c49340a7c7a81951befb01e69dff..796273299f9eb920223fc5e0aa8806d6979982b0 100644 --- hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java +++ hcatalog/server-extensions/src/main/java/org/apache/hive/hcatalog/messaging/json/JSONMessageFactory.java @@ -95,37 +95,40 @@ public DropDatabaseMessage buildDropDatabaseMessage(Database db) { @Override public CreateTableMessage buildCreateTableMessage(Table table) { return new JSONCreateTableMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), - table.getTableName(), now()); + table.getTableName(), table.getTableType(), now()); } @Override public AlterTableMessage buildAlterTableMessage(Table before, Table after) { return new JSONAlterTableMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, before.getDbName(), - before.getTableName(), now()); + before.getTableName(), before.getTableType(), now()); } @Override public DropTableMessage buildDropTableMessage(Table table) { - return new JSONDropTableMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), table.getTableName(), - now()); + return new JSONDropTableMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), + table.getTableName(), table.getTableType(), now()); } @Override public AddPartitionMessage buildAddPartitionMessage(Table table, Iterator partitionsIterator) { return new JSONAddPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), - table.getTableName(), getPartitionKeyValues(table, partitionsIterator), now()); + table.getTableName(), table.getTableType(), + getPartitionKeyValues(table, partitionsIterator), now()); } @Override public AlterPartitionMessage buildAlterPartitionMessage(Table table, Partition before, Partition after) { return new JSONAlterPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, - before.getDbName(), before.getTableName(), getPartitionKeyValues(table,before),now()); + before.getDbName(), before.getTableName(), table.getTableType(), + getPartitionKeyValues(table,before),now()); } @Override public DropPartitionMessage buildDropPartitionMessage(Table table, Iterator partitions) { return new JSONDropPartitionMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), - table.getTableName(), getPartitionKeyValues(table, partitions), now()); + table.getTableName(), table.getTableType(), + getPartitionKeyValues(table, partitions), now()); } @Override @@ -161,8 +164,15 @@ public AlterIndexMessage buildAlterIndexMessage(Index before, Index after) { @Override public InsertMessage buildInsertMessage(String db, String table, Map partKeyVals, List files) { - return new JSONInsertMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, db, table, partKeyVals, - files, now()); + return new JSONInsertMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, db, table, null, + partKeyVals, files, now()); + } + + @Override + public InsertMessage buildInsertMessage(String db, Table table, Map partKeyVals, + List files) { + return new JSONInsertMessage(HCAT_SERVER_URL, HCAT_SERVICE_PRINCIPAL, table.getDbName(), + table.getTableName(), table.getTableType(), partKeyVals, files, now()); } private long now() { diff --git hcatalog/server-extensions/src/test/java/org/apache/hive/hcatalog/listener/TestNotificationListener.java hcatalog/server-extensions/src/test/java/org/apache/hive/hcatalog/listener/TestNotificationListener.java index ef7b575b23a9724a13dbff8f65c8028e91999f5d..3a334030bf6933861b9acf3288706603982de354 100644 --- hcatalog/server-extensions/src/test/java/org/apache/hive/hcatalog/listener/TestNotificationListener.java +++ hcatalog/server-extensions/src/test/java/org/apache/hive/hcatalog/listener/TestNotificationListener.java @@ -42,6 +42,7 @@ import org.apache.hadoop.hive.conf.HiveConf; import org.apache.hadoop.hive.conf.HiveConf.ConfVars; import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; +import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.metastore.api.PartitionEventType; import org.apache.hadoop.hive.ql.Driver; import org.apache.hadoop.hive.ql.session.SessionState; @@ -168,6 +169,7 @@ public void onMessage(Message msg) { CreateTableMessage message = deserializer.getCreateTableMessage(messageBody); Assert.assertEquals("mytbl", message.getTable()); Assert.assertEquals("mydb", message.getDB()); + Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType()); HCatEventMessage message2 = MessagingUtils.getMessage(msg); Assert.assertTrue("Unexpected message-type.", message2 instanceof CreateTableMessage); Assert.assertEquals("mydb", message2.getDB()); @@ -181,6 +183,7 @@ public void onMessage(Message msg) { Assert.assertEquals("mydb", message.getDB()); Assert.assertEquals(1, message.getPartitions().size()); Assert.assertEquals("2011", message.getPartitions().get(0).get("b")); + Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType()); HCatEventMessage message2 = MessagingUtils.getMessage(msg); Assert.assertTrue("Unexpected message-type.", message2 instanceof AddPartitionMessage); Assert.assertEquals("mydb", message2.getDB()); @@ -195,6 +198,7 @@ public void onMessage(Message msg) { Assert.assertEquals("mydb", message.getDB()); Assert.assertEquals(1, message.getKeyValues().size()); Assert.assertTrue(message.getKeyValues().values().contains("2011")); + Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType()); HCatEventMessage message2 = MessagingUtils.getMessage(msg); Assert.assertTrue("Unexpected message-type.", message2 instanceof AlterPartitionMessage); Assert.assertEquals("mydb", message2.getDB()); @@ -210,6 +214,7 @@ public void onMessage(Message msg) { Assert.assertEquals("mydb", message.getDB()); Assert.assertEquals(1, message.getPartitions().size()); Assert.assertEquals("2011", message.getPartitions().get(0).get("b")); + Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType()); HCatEventMessage message2 = MessagingUtils.getMessage(msg); Assert.assertTrue("Unexpected message-type.", message2 instanceof DropPartitionMessage); Assert.assertEquals("mydb", message2.getDB()); @@ -223,6 +228,7 @@ public void onMessage(Message msg) { DropTableMessage message = deserializer.getDropTableMessage(messageBody); Assert.assertEquals("mytbl", message.getTable()); Assert.assertEquals("mydb", message.getDB()); + Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType()); HCatEventMessage message2 = MessagingUtils.getMessage(msg); Assert.assertTrue("Unexpected message-type.", message2 instanceof DropTableMessage); Assert.assertEquals("mydb", message2.getDB()); @@ -241,6 +247,7 @@ public void onMessage(Message msg) { AlterTableMessage message = deserializer.getAlterTableMessage(messageBody); Assert.assertEquals("mytbl", message.getTable()); Assert.assertEquals("mydb", message.getDB()); + Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType()); HCatEventMessage message2 = MessagingUtils.getMessage(msg); Assert.assertTrue("Unexpected message-type.", message2 instanceof AlterTableMessage); Assert.assertEquals("mydb", message2.getDB()); diff --git itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/api/TestHCatClientNotification.java itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/api/TestHCatClientNotification.java index c09e6879f010c3f6c11e999e27c8f11a9617f652..b9a32180eeee91fe1da58c5397b0e78463e3e141 100644 --- itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/api/TestHCatClientNotification.java +++ itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/api/TestHCatClientNotification.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import org.apache.hadoop.hive.metastore.TableType; import org.apache.hive.hcatalog.messaging.AddPartitionMessage; import org.apache.hive.hcatalog.messaging.CreateDatabaseMessage; import org.apache.hive.hcatalog.messaging.CreateTableMessage; @@ -137,6 +138,7 @@ public void createTable() throws Exception { CreateTableMessage createTableMessage = md.getCreateTableMessage(event.getMessage()); assertEquals(dbName, createTableMessage.getDB()); assertEquals(tableName, createTableMessage.getTable()); + assertEquals(TableType.MANAGED_TABLE.toString(), createTableMessage.getTableType()); // fetch the table marked by the message and compare HCatTable createdTable = hCatClient.getTable(dbName,tableName); @@ -167,6 +169,7 @@ public void dropTable() throws Exception { DropTableMessage dropTableMessage = md.getDropTableMessage(event.getMessage()); assertEquals(dbName, dropTableMessage.getDB()); assertEquals(tableName, dropTableMessage.getTable()); + assertEquals(TableType.MANAGED_TABLE.toString(), dropTableMessage.getTableType()); } @Test @@ -198,6 +201,7 @@ public void addPartition() throws Exception { AddPartitionMessage addPartitionMessage = md.getAddPartitionMessage(event.getMessage()); assertEquals(dbName, addPartitionMessage.getDB()); assertEquals(tableName, addPartitionMessage.getTable()); + assertEquals(TableType.MANAGED_TABLE.toString(), addPartitionMessage.getTableType()); List> ptndescs = addPartitionMessage.getPartitions(); // fetch the partition referred to by the message and compare @@ -245,6 +249,7 @@ public void dropPartition() throws Exception { DropPartitionMessage dropPartitionMessage = md.getDropPartitionMessage(event.getMessage()); assertEquals(dbName, dropPartitionMessage.getDB()); assertEquals(tableName, dropPartitionMessage.getTable()); + assertEquals(TableType.MANAGED_TABLE.toString(), dropPartitionMessage.getTableType()); List> droppedPartSpecs = dropPartitionMessage.getPartitions(); assertNotNull(droppedPartSpecs); assertEquals(1,droppedPartSpecs.size()); diff --git itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java index 808c9c7c36fd0ba36adac7be942c4841ab0a08a8..564e43cdffd613577f213d10cac008b94a0c4396 100644 --- itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java +++ itests/hcatalog-unit/src/test/java/org/apache/hive/hcatalog/listener/TestDbNotificationListener.java @@ -41,6 +41,7 @@ import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; import org.apache.hadoop.hive.metastore.IMetaStoreClient; import org.apache.hadoop.hive.metastore.MetaStoreEventListener; +import org.apache.hadoop.hive.metastore.TableType; import org.apache.hadoop.hive.metastore.api.Database; import org.apache.hadoop.hive.metastore.api.FieldSchema; import org.apache.hadoop.hive.metastore.api.FireEventRequest; @@ -383,7 +384,7 @@ public void createTable() throws Exception { emptyParameters); Table table = new Table(tblName, defaultDbName, tblOwner, startTime, startTime, 0, sd, null, - emptyParameters, null, null, null); + emptyParameters, null, null, TableType.MANAGED_TABLE.toString()); msClient.createTable(table); // Get notifications from metastore @@ -401,6 +402,7 @@ public void createTable() throws Exception { assertEquals(defaultDbName, createTblMsg.getDB()); assertEquals(tblName, createTblMsg.getTable()); assertEquals(table, createTblMsg.getTableObj()); + assertEquals(TableType.MANAGED_TABLE.toString(), createTblMsg.getTableType()); // Verify the eventID was passed to the non-transactional listener MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_TABLE, firstEventId + 1); @@ -460,6 +462,7 @@ public void alterTable() throws Exception { AlterTableMessage alterTableMessage = md.getAlterTableMessage(event.getMessage()); assertEquals(table, alterTableMessage.getTableObjAfter()); + assertEquals(TableType.MANAGED_TABLE.toString(), alterTableMessage.getTableType()); // Verify the eventID was passed to the non-transactional listener MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_TABLE, firstEventId + 1); @@ -514,6 +517,7 @@ public void dropTable() throws Exception { DropTableMessage dropTblMsg = md.getDropTableMessage(event.getMessage()); assertEquals(defaultDbName, dropTblMsg.getDB()); assertEquals(tblName, dropTblMsg.getTable()); + assertEquals(TableType.MANAGED_TABLE.toString(), dropTblMsg.getTableType()); // Verify the eventID was passed to the non-transactional listener MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.DROP_TABLE, firstEventId + 2); @@ -583,6 +587,7 @@ public void addPartition() throws Exception { Iterator ptnIter = addPtnMsg.getPartitionObjs().iterator(); assertTrue(ptnIter.hasNext()); assertEquals(partition, ptnIter.next()); + assertEquals(TableType.MANAGED_TABLE.toString(), addPtnMsg.getTableType()); // Verify the eventID was passed to the non-transactional listener MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.ADD_PARTITION, firstEventId + 2); @@ -653,6 +658,7 @@ public void alterPartition() throws Exception { assertEquals(defaultDbName, alterPtnMsg.getDB()); assertEquals(tblName, alterPtnMsg.getTable()); assertEquals(newPart, alterPtnMsg.getPtnObjAfter()); + assertEquals(TableType.MANAGED_TABLE.toString(), alterPtnMsg.getTableType()); // Verify the eventID was passed to the non-transactional listener MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.ADD_PARTITION, firstEventId + 2); @@ -720,6 +726,7 @@ public void dropPartition() throws Exception { assertEquals(table.getDbName(), tableObj.getDbName()); assertEquals(table.getTableName(), tableObj.getTableName()); assertEquals(table.getOwner(), tableObj.getOwner()); + assertEquals(TableType.MANAGED_TABLE.toString(), dropPtnMsg.getTableType()); // Verify the eventID was passed to the non-transactional listener MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.DROP_PARTITION, firstEventId + 3); @@ -802,6 +809,8 @@ public void exchangePartition() throws Exception { assertEquals(dbName, addPtnMsg.getDB()); assertEquals(tab2.getTableName(), addPtnMsg.getTable()); Iterator ptnIter = addPtnMsg.getPartitionObjs().iterator(); + assertEquals(TableType.MANAGED_TABLE.toString(), addPtnMsg.getTableType()); + assertTrue(ptnIter.hasNext()); Partition msgPart = ptnIter.next(); assertEquals(part1.getValues(), msgPart.getValues()); @@ -819,6 +828,7 @@ public void exchangePartition() throws Exception { DropPartitionMessage dropPtnMsg = md.getDropPartitionMessage(event.getMessage()); assertEquals(dbName, dropPtnMsg.getDB()); assertEquals(tab1.getTableName(), dropPtnMsg.getTable()); + assertEquals(TableType.MANAGED_TABLE.toString(), dropPtnMsg.getTableType()); Iterator> parts = dropPtnMsg.getPartitions().iterator(); assertTrue(parts.hasNext()); assertEquals(part1.getValues(), Lists.newArrayList(parts.next().values())); @@ -1204,6 +1214,12 @@ public void insertTable() throws Exception { // Parse the message field verifyInsert(event, defaultDbName, tblName); + // Parse the message field + InsertMessage insertMessage = md.getInsertMessage(event.getMessage()); + assertEquals(defaultDbName, insertMessage.getDB()); + assertEquals(tblName, insertMessage.getTable()); + assertEquals(TableType.MANAGED_TABLE.toString(), insertMessage.getTableType()); + // Verify the eventID was passed to the non-transactional listener MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.INSERT, firstEventId + 2); MockMetaStoreEventListener.popAndVerifyLastEventId(EventType.CREATE_TABLE, firstEventId + 1); diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AddPartitionMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AddPartitionMessage.java index 28f110140db4f67c9b3fb0d55e835bb1b23201ca..774c020ff5c0262c7fb4dee355c8215e42b2d2ed 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AddPartitionMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AddPartitionMessage.java @@ -37,6 +37,8 @@ protected AddPartitionMessage() { */ public abstract String getTable(); + public abstract String getTableType(); + public abstract Table getTableObj() throws Exception; /** diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java index e9ed7e5b3b4336eb2b1a99177e9f5f5f286108df..077c9f7e9ccf61a8782a000a99219563f699bead 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterPartitionMessage.java @@ -31,6 +31,8 @@ protected AlterPartitionMessage() { public abstract String getTable(); + public abstract String getTableType(); + public abstract boolean getIsTruncateOp(); public abstract Map getKeyValues(); diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java index 39a87bcfd1056ed1b0f7403215e72ab5329627f3..58f01fe12677493ec4eb24401229b2ff3d5bbaf7 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/AlterTableMessage.java @@ -28,6 +28,8 @@ protected AlterTableMessage() { public abstract String getTable(); + public abstract String getTableType(); + public abstract boolean getIsTruncateOp(); public abstract Table getTableObjBefore() throws Exception; diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java index 441fd84a8c4098daf438de50a1901a033656c505..b75caa6351635b8573d789c31b0e60e9f59a09bb 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/CreateTableMessage.java @@ -33,6 +33,8 @@ protected CreateTableMessage() { */ public abstract String getTable(); + public abstract String getTableType(); + public abstract Table getTableObj() throws Exception; /** diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java index 0dd3e50a1cd78153ba79449373a195ffd81b2f0f..d254ad93f6d53eb0edc354ab9a9826fb8eb68248 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropPartitionMessage.java @@ -32,6 +32,8 @@ protected DropPartitionMessage() { public abstract String getTable(); + public abstract String getTableType(); + public abstract Table getTableObj() throws Exception; public abstract List> getPartitions (); diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java index 64a8cc529a03b1782dd906b7ab32bd1e5787cfa3..03f73f180b187ecd24b7755f4ae33944c29dde3e 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/DropTableMessage.java @@ -31,6 +31,8 @@ protected DropTableMessage() { */ public abstract String getTable(); + public abstract String getTableType(); + @Override public EventMessage checkValid() { if (getTable() == null) diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java index 6505c67cb283172761786e02511467319029da1c..01fc0f2cdebb007d31350f43d92cd0fab779968f 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/InsertMessage.java @@ -37,6 +37,8 @@ protected InsertMessage() { */ public abstract String getTable(); + public abstract String getTableType(); + /** * Getter for the replace flag being insert into/overwrite * @return Replace flag to represent INSERT INTO or INSERT OVERWRITE (Boolean). diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java index a48820569cf996baa5d7d4d3fe434d617aa109a9..db3431eac9395a5340c7abec5412980e37ca207d 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAddPartitionMessage.java @@ -43,7 +43,7 @@ public class JSONAddPartitionMessage extends AddPartitionMessage { @JsonProperty - String server, servicePrincipal, db, table, tableObjJson; + String server, servicePrincipal, db, table, tableType, tableObjJson; @JsonProperty Long timestamp; @@ -73,6 +73,7 @@ public JSONAddPartitionMessage(String server, String servicePrincipal, Table tab this.servicePrincipal = servicePrincipal; this.db = tableObj.getDbName(); this.table = tableObj.getTableName(); + this.tableType = tableObj.getTableType(); this.timestamp = timestamp; partitions = new ArrayList>(); partitionListJson = new ArrayList(); @@ -112,6 +113,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public Table getTableObj() throws Exception { return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class); } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java index bd7776c5d3d588dfe4358a01dc76aa0cfa140320..2991e08836a11593d467b98b3aebe830fd626b07 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterPartitionMessage.java @@ -34,7 +34,7 @@ public class JSONAlterPartitionMessage extends AlterPartitionMessage { @JsonProperty - String server, servicePrincipal, db, table, tableObjJson; + String server, servicePrincipal, db, table, tableType, tableObjJson; @JsonProperty String isTruncateOp; @@ -60,6 +60,7 @@ public JSONAlterPartitionMessage(String server, String servicePrincipal, Table t this.servicePrincipal = servicePrincipal; this.db = tableObj.getDbName(); this.table = tableObj.getTableName(); + this.tableType = tableObj.getTableType(); this.isTruncateOp = Boolean.toString(isTruncateOp); this.timestamp = timestamp; this.keyValues = JSONMessageFactory.getPartitionKeyValues(tableObj, partitionObjBefore); @@ -99,6 +100,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public boolean getIsTruncateOp() { return Boolean.parseBoolean(isTruncateOp); } @Override diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java index 58eb1a72f07632e8a2db0bfc740cd6874789cb81..1df9c8b15988a324aadf161b736125f39212372d 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONAlterTableMessage.java @@ -29,7 +29,7 @@ public class JSONAlterTableMessage extends AlterTableMessage { @JsonProperty - String server, servicePrincipal, db, table, tableObjBeforeJson, tableObjAfterJson; + String server, servicePrincipal, db, table, tableType, tableObjBeforeJson, tableObjAfterJson; @JsonProperty String isTruncateOp; @@ -49,6 +49,7 @@ public JSONAlterTableMessage(String server, String servicePrincipal, Table table this.servicePrincipal = servicePrincipal; this.db = tableObjBefore.getDbName(); this.table = tableObjBefore.getTableName(); + this.tableType = tableObjBefore.getTableType(); this.isTruncateOp = Boolean.toString(isTruncateOp); this.timestamp = timestamp; try { @@ -86,6 +87,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public boolean getIsTruncateOp() { return Boolean.parseBoolean(isTruncateOp); } @Override diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java index dbc3dd4b49e63d221ebb312644884cc67f3d6d2f..9dd7a744c197c4bfb6fd138339dd9beab94ac499 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONCreateTableMessage.java @@ -35,7 +35,7 @@ public class JSONCreateTableMessage extends CreateTableMessage { @JsonProperty - String server, servicePrincipal, db, table, tableObjJson; + String server, servicePrincipal, db, table, tableType, tableObjJson; @JsonProperty Long timestamp; @JsonProperty @@ -48,18 +48,25 @@ public JSONCreateTableMessage() { } public JSONCreateTableMessage(String server, String servicePrincipal, String db, String table, - Long timestamp) { + String tableType, Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.timestamp = timestamp; checkValid(); } + public JSONCreateTableMessage(String server, String servicePrincipal, String db, String table, + Long timestamp) { + this(server, servicePrincipal, db, table, null, timestamp); + } + public JSONCreateTableMessage(String server, String servicePrincipal, Table tableObj, Iterator fileIter, Long timestamp) { - this(server, servicePrincipal, tableObj.getDbName(), tableObj.getTableName(), timestamp); + this(server, servicePrincipal, tableObj.getDbName(), tableObj.getTableName(), + tableObj.getTableType(), timestamp); try { this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj); } catch (TException e) { @@ -94,6 +101,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public Table getTableObj() throws Exception { return (Table) JSONMessageFactory.getTObj(tableObjJson,Table.class); } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java index f1860af191cba49e43a1937253f349c0bb07b1c2..576806cf62d0d0fa1a2016715a762f63aba84455 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropPartitionMessage.java @@ -33,7 +33,7 @@ public class JSONDropPartitionMessage extends DropPartitionMessage { @JsonProperty - String server, servicePrincipal, db, table, tableObjJson; + String server, servicePrincipal, db, table, tableType, tableObjJson; @JsonProperty Long timestamp; @@ -49,10 +49,16 @@ public JSONDropPartitionMessage() { public JSONDropPartitionMessage(String server, String servicePrincipal, String db, String table, List> partitions, Long timestamp) { + this(server, servicePrincipal, db, table, null, partitions, timestamp); + } + + public JSONDropPartitionMessage(String server, String servicePrincipal, String db, String table, + String tableType, List> partitions, Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.partitions = partitions; this.timestamp = timestamp; checkValid(); @@ -61,7 +67,7 @@ public JSONDropPartitionMessage(String server, String servicePrincipal, String d public JSONDropPartitionMessage(String server, String servicePrincipal, Table tableObj, List> partitionKeyValues, long timestamp) { this(server, servicePrincipal, tableObj.getDbName(), tableObj.getTableName(), - partitionKeyValues, timestamp); + tableObj.getTableType(), partitionKeyValues, timestamp); try { this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj); } catch (TException e) { @@ -90,6 +96,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public Long getTimestamp() { return timestamp; } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java index 635ab6133b89f29d3a1f3b7b7be45c1b3b26a89b..17f38ba1234e13240059f28c2474e5e923ab008a 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONDropTableMessage.java @@ -28,7 +28,7 @@ public class JSONDropTableMessage extends DropTableMessage { @JsonProperty - String server, servicePrincipal, db, table; + String server, servicePrincipal, db, table, tableType; @JsonProperty Long timestamp; @@ -41,10 +41,16 @@ public JSONDropTableMessage() { public JSONDropTableMessage(String server, String servicePrincipal, String db, String table, Long timestamp) { + this(server, servicePrincipal, db, table, null, timestamp); + } + + public JSONDropTableMessage(String server, String servicePrincipal, String db, String table, + String tableType, Long timestamp) { this.server = server; this.servicePrincipal = servicePrincipal; this.db = db; this.table = table; + this.tableType = tableType; this.timestamp = timestamp; checkValid(); } @@ -55,6 +61,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public String getServer() { return server; } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java index 18a15f5ac2149d742200e075749484ba129a55de..1369fd2f3b037d49882d72c1564269b7b8a3dddc 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONInsertMessage.java @@ -36,7 +36,7 @@ public class JSONInsertMessage extends InsertMessage { @JsonProperty - String server, servicePrincipal, db, table, tableObjJson, ptnObjJson; + String server, servicePrincipal, db, table, tableType, tableObjJson, ptnObjJson; @JsonProperty Long timestamp; @@ -64,6 +64,7 @@ public JSONInsertMessage(String server, String servicePrincipal, Table tableObj, this.db = tableObj.getDbName(); this.table = tableObj.getTableName(); + this.tableType = tableObj.getTableType(); try { this.tableObjJson = JSONMessageFactory.createTableObjJson(tableObj); @@ -89,6 +90,11 @@ public String getTable() { } @Override + public String getTableType() { + if (tableType != null) return tableType; else return ""; + } + + @Override public String getServer() { return server; } diff --git metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java index a4c31f28f57cae736df9a9627c998c72a158343e..b24d1e392b6fb5666231cd2a20fff55fb994191f 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/messaging/json/JSONMessageFactory.java @@ -111,7 +111,7 @@ public AlterTableMessage buildAlterTableMessage(Table before, Table after, boole @Override public DropTableMessage buildDropTableMessage(Table table) { return new JSONDropTableMessage(MS_SERVER_URL, MS_SERVICE_PRINCIPAL, table.getDbName(), - table.getTableName(), now()); + table.getTableName(), table.getTableType(), now()); } @Override