diff --git itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java
index 767321332c..0e08e81f20 100644
--- itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java
+++ itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestMetastoreAuthorizationProvider.java
@@ -49,6 +49,7 @@
import org.apache.hadoop.hive.serde.serdeConstants;
import org.apache.hadoop.hive.shims.Utils;
import org.apache.hadoop.security.UserGroupInformation;
+import org.junit.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -238,6 +239,8 @@ public void testSimplePrivileges() throws Exception {
assertEquals(0,ret.getResponseCode()); // now it succeeds.
Table tbl = msc.getTable(dbName, tblName);
+ Assert.assertTrue(tbl.isSetId());
+ tbl.unsetId();
validateCreateTable(tbl,tblName, dbName);
diff --git ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
index 8aa971a639..9f187680c9 100644
--- ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
+++ ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java
@@ -5103,6 +5103,7 @@ private int createTableLike(Hive db, CreateTableLikeDesc crtTbl) throws Exceptio
}
tbl.getTTable().setTemporary(crtTbl.isTemporary());
+ tbl.getTTable().unsetId();
if (crtTbl.isExternal()) {
tbl.setProperty("EXTERNAL", "TRUE");
diff --git ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java
index ca4d36f30d..76a5050fb9 100755
--- ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java
+++ ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHive.java
@@ -330,6 +330,11 @@ private void validateTable(Table tbl, String tableName) throws MetaException {
ft.getTTable().setWriteId(0);
tbl.getTTable().setWriteId(0);
}
+
+ // Id is a read-only value so it shouldn't be set in the original table
+ assertTrue(ft.getTTable().isSetId());
+ ft.getTTable().unsetId();
+
assertTrue("Tables doesn't match: " + tableName + " (" + ft.getTTable()
+ "; " + tbl.getTTable() + ")", ft.getTTable().equals(tbl.getTTable()));
assertEquals("SerializationLib is not set correctly", tbl
diff --git standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java
index 78ac909f72..8c2988cbaa 100644
--- standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java
+++ standalone-metastore/metastore-common/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Table.java
@@ -38,26 +38,27 @@
@org.apache.hadoop.classification.InterfaceAudience.Public @org.apache.hadoop.classification.InterfaceStability.Stable public class Table implements org.apache.thrift.TBase
, java.io.Serializable, Cloneable, Comparable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("Table");
- private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short)1);
- private static final org.apache.thrift.protocol.TField DB_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("dbName", org.apache.thrift.protocol.TType.STRING, (short)2);
- private static final org.apache.thrift.protocol.TField OWNER_FIELD_DESC = new org.apache.thrift.protocol.TField("owner", org.apache.thrift.protocol.TType.STRING, (short)3);
- private static final org.apache.thrift.protocol.TField CREATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createTime", org.apache.thrift.protocol.TType.I32, (short)4);
- private static final org.apache.thrift.protocol.TField LAST_ACCESS_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("lastAccessTime", org.apache.thrift.protocol.TType.I32, (short)5);
- private static final org.apache.thrift.protocol.TField RETENTION_FIELD_DESC = new org.apache.thrift.protocol.TField("retention", org.apache.thrift.protocol.TType.I32, (short)6);
- private static final org.apache.thrift.protocol.TField SD_FIELD_DESC = new org.apache.thrift.protocol.TField("sd", org.apache.thrift.protocol.TType.STRUCT, (short)7);
- private static final org.apache.thrift.protocol.TField PARTITION_KEYS_FIELD_DESC = new org.apache.thrift.protocol.TField("partitionKeys", org.apache.thrift.protocol.TType.LIST, (short)8);
- private static final org.apache.thrift.protocol.TField PARAMETERS_FIELD_DESC = new org.apache.thrift.protocol.TField("parameters", org.apache.thrift.protocol.TType.MAP, (short)9);
- private static final org.apache.thrift.protocol.TField VIEW_ORIGINAL_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("viewOriginalText", org.apache.thrift.protocol.TType.STRING, (short)10);
- private static final org.apache.thrift.protocol.TField VIEW_EXPANDED_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("viewExpandedText", org.apache.thrift.protocol.TType.STRING, (short)11);
- private static final org.apache.thrift.protocol.TField TABLE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("tableType", org.apache.thrift.protocol.TType.STRING, (short)12);
- private static final org.apache.thrift.protocol.TField PRIVILEGES_FIELD_DESC = new org.apache.thrift.protocol.TField("privileges", org.apache.thrift.protocol.TType.STRUCT, (short)13);
- private static final org.apache.thrift.protocol.TField TEMPORARY_FIELD_DESC = new org.apache.thrift.protocol.TField("temporary", org.apache.thrift.protocol.TType.BOOL, (short)14);
- private static final org.apache.thrift.protocol.TField REWRITE_ENABLED_FIELD_DESC = new org.apache.thrift.protocol.TField("rewriteEnabled", org.apache.thrift.protocol.TType.BOOL, (short)15);
- private static final org.apache.thrift.protocol.TField CREATION_METADATA_FIELD_DESC = new org.apache.thrift.protocol.TField("creationMetadata", org.apache.thrift.protocol.TType.STRUCT, (short)16);
- private static final org.apache.thrift.protocol.TField CAT_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("catName", org.apache.thrift.protocol.TType.STRING, (short)17);
- private static final org.apache.thrift.protocol.TField OWNER_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("ownerType", org.apache.thrift.protocol.TType.I32, (short)18);
- private static final org.apache.thrift.protocol.TField WRITE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("writeId", org.apache.thrift.protocol.TType.I64, (short)19);
- private static final org.apache.thrift.protocol.TField IS_STATS_COMPLIANT_FIELD_DESC = new org.apache.thrift.protocol.TField("isStatsCompliant", org.apache.thrift.protocol.TType.BOOL, (short)20);
+ private static final org.apache.thrift.protocol.TField ID_FIELD_DESC = new org.apache.thrift.protocol.TField("id", org.apache.thrift.protocol.TType.I64, (short)1);
+ private static final org.apache.thrift.protocol.TField TABLE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("tableName", org.apache.thrift.protocol.TType.STRING, (short)2);
+ private static final org.apache.thrift.protocol.TField DB_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("dbName", org.apache.thrift.protocol.TType.STRING, (short)3);
+ private static final org.apache.thrift.protocol.TField OWNER_FIELD_DESC = new org.apache.thrift.protocol.TField("owner", org.apache.thrift.protocol.TType.STRING, (short)4);
+ private static final org.apache.thrift.protocol.TField CREATE_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("createTime", org.apache.thrift.protocol.TType.I32, (short)5);
+ private static final org.apache.thrift.protocol.TField LAST_ACCESS_TIME_FIELD_DESC = new org.apache.thrift.protocol.TField("lastAccessTime", org.apache.thrift.protocol.TType.I32, (short)6);
+ private static final org.apache.thrift.protocol.TField RETENTION_FIELD_DESC = new org.apache.thrift.protocol.TField("retention", org.apache.thrift.protocol.TType.I32, (short)7);
+ private static final org.apache.thrift.protocol.TField SD_FIELD_DESC = new org.apache.thrift.protocol.TField("sd", org.apache.thrift.protocol.TType.STRUCT, (short)8);
+ private static final org.apache.thrift.protocol.TField PARTITION_KEYS_FIELD_DESC = new org.apache.thrift.protocol.TField("partitionKeys", org.apache.thrift.protocol.TType.LIST, (short)9);
+ private static final org.apache.thrift.protocol.TField PARAMETERS_FIELD_DESC = new org.apache.thrift.protocol.TField("parameters", org.apache.thrift.protocol.TType.MAP, (short)10);
+ private static final org.apache.thrift.protocol.TField VIEW_ORIGINAL_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("viewOriginalText", org.apache.thrift.protocol.TType.STRING, (short)11);
+ private static final org.apache.thrift.protocol.TField VIEW_EXPANDED_TEXT_FIELD_DESC = new org.apache.thrift.protocol.TField("viewExpandedText", org.apache.thrift.protocol.TType.STRING, (short)12);
+ private static final org.apache.thrift.protocol.TField TABLE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("tableType", org.apache.thrift.protocol.TType.STRING, (short)13);
+ private static final org.apache.thrift.protocol.TField PRIVILEGES_FIELD_DESC = new org.apache.thrift.protocol.TField("privileges", org.apache.thrift.protocol.TType.STRUCT, (short)14);
+ private static final org.apache.thrift.protocol.TField TEMPORARY_FIELD_DESC = new org.apache.thrift.protocol.TField("temporary", org.apache.thrift.protocol.TType.BOOL, (short)15);
+ private static final org.apache.thrift.protocol.TField REWRITE_ENABLED_FIELD_DESC = new org.apache.thrift.protocol.TField("rewriteEnabled", org.apache.thrift.protocol.TType.BOOL, (short)16);
+ private static final org.apache.thrift.protocol.TField CREATION_METADATA_FIELD_DESC = new org.apache.thrift.protocol.TField("creationMetadata", org.apache.thrift.protocol.TType.STRUCT, (short)17);
+ private static final org.apache.thrift.protocol.TField CAT_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("catName", org.apache.thrift.protocol.TType.STRING, (short)18);
+ private static final org.apache.thrift.protocol.TField OWNER_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("ownerType", org.apache.thrift.protocol.TType.I32, (short)19);
+ private static final org.apache.thrift.protocol.TField WRITE_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("writeId", org.apache.thrift.protocol.TType.I64, (short)20);
+ private static final org.apache.thrift.protocol.TField IS_STATS_COMPLIANT_FIELD_DESC = new org.apache.thrift.protocol.TField("isStatsCompliant", org.apache.thrift.protocol.TType.BOOL, (short)21);
private static final Map, SchemeFactory> schemes = new HashMap, SchemeFactory>();
static {
@@ -65,6 +66,7 @@
schemes.put(TupleScheme.class, new TableTupleSchemeFactory());
}
+ private long id; // optional
private String tableName; // required
private String dbName; // required
private String owner; // required
@@ -88,30 +90,31 @@
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
- TABLE_NAME((short)1, "tableName"),
- DB_NAME((short)2, "dbName"),
- OWNER((short)3, "owner"),
- CREATE_TIME((short)4, "createTime"),
- LAST_ACCESS_TIME((short)5, "lastAccessTime"),
- RETENTION((short)6, "retention"),
- SD((short)7, "sd"),
- PARTITION_KEYS((short)8, "partitionKeys"),
- PARAMETERS((short)9, "parameters"),
- VIEW_ORIGINAL_TEXT((short)10, "viewOriginalText"),
- VIEW_EXPANDED_TEXT((short)11, "viewExpandedText"),
- TABLE_TYPE((short)12, "tableType"),
- PRIVILEGES((short)13, "privileges"),
- TEMPORARY((short)14, "temporary"),
- REWRITE_ENABLED((short)15, "rewriteEnabled"),
- CREATION_METADATA((short)16, "creationMetadata"),
- CAT_NAME((short)17, "catName"),
+ ID((short)1, "id"),
+ TABLE_NAME((short)2, "tableName"),
+ DB_NAME((short)3, "dbName"),
+ OWNER((short)4, "owner"),
+ CREATE_TIME((short)5, "createTime"),
+ LAST_ACCESS_TIME((short)6, "lastAccessTime"),
+ RETENTION((short)7, "retention"),
+ SD((short)8, "sd"),
+ PARTITION_KEYS((short)9, "partitionKeys"),
+ PARAMETERS((short)10, "parameters"),
+ VIEW_ORIGINAL_TEXT((short)11, "viewOriginalText"),
+ VIEW_EXPANDED_TEXT((short)12, "viewExpandedText"),
+ TABLE_TYPE((short)13, "tableType"),
+ PRIVILEGES((short)14, "privileges"),
+ TEMPORARY((short)15, "temporary"),
+ REWRITE_ENABLED((short)16, "rewriteEnabled"),
+ CREATION_METADATA((short)17, "creationMetadata"),
+ CAT_NAME((short)18, "catName"),
/**
*
* @see PrincipalType
*/
- OWNER_TYPE((short)18, "ownerType"),
- WRITE_ID((short)19, "writeId"),
- IS_STATS_COMPLIANT((short)20, "isStatsCompliant");
+ OWNER_TYPE((short)19, "ownerType"),
+ WRITE_ID((short)20, "writeId"),
+ IS_STATS_COMPLIANT((short)21, "isStatsCompliant");
private static final Map byName = new HashMap();
@@ -126,45 +129,47 @@
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
- case 1: // TABLE_NAME
+ case 1: // ID
+ return ID;
+ case 2: // TABLE_NAME
return TABLE_NAME;
- case 2: // DB_NAME
+ case 3: // DB_NAME
return DB_NAME;
- case 3: // OWNER
+ case 4: // OWNER
return OWNER;
- case 4: // CREATE_TIME
+ case 5: // CREATE_TIME
return CREATE_TIME;
- case 5: // LAST_ACCESS_TIME
+ case 6: // LAST_ACCESS_TIME
return LAST_ACCESS_TIME;
- case 6: // RETENTION
+ case 7: // RETENTION
return RETENTION;
- case 7: // SD
+ case 8: // SD
return SD;
- case 8: // PARTITION_KEYS
+ case 9: // PARTITION_KEYS
return PARTITION_KEYS;
- case 9: // PARAMETERS
+ case 10: // PARAMETERS
return PARAMETERS;
- case 10: // VIEW_ORIGINAL_TEXT
+ case 11: // VIEW_ORIGINAL_TEXT
return VIEW_ORIGINAL_TEXT;
- case 11: // VIEW_EXPANDED_TEXT
+ case 12: // VIEW_EXPANDED_TEXT
return VIEW_EXPANDED_TEXT;
- case 12: // TABLE_TYPE
+ case 13: // TABLE_TYPE
return TABLE_TYPE;
- case 13: // PRIVILEGES
+ case 14: // PRIVILEGES
return PRIVILEGES;
- case 14: // TEMPORARY
+ case 15: // TEMPORARY
return TEMPORARY;
- case 15: // REWRITE_ENABLED
+ case 16: // REWRITE_ENABLED
return REWRITE_ENABLED;
- case 16: // CREATION_METADATA
+ case 17: // CREATION_METADATA
return CREATION_METADATA;
- case 17: // CAT_NAME
+ case 18: // CAT_NAME
return CAT_NAME;
- case 18: // OWNER_TYPE
+ case 19: // OWNER_TYPE
return OWNER_TYPE;
- case 19: // WRITE_ID
+ case 20: // WRITE_ID
return WRITE_ID;
- case 20: // IS_STATS_COMPLIANT
+ case 21: // IS_STATS_COMPLIANT
return IS_STATS_COMPLIANT;
default:
return null;
@@ -206,18 +211,21 @@ public String getFieldName() {
}
// isset id assignments
- private static final int __CREATETIME_ISSET_ID = 0;
- private static final int __LASTACCESSTIME_ISSET_ID = 1;
- private static final int __RETENTION_ISSET_ID = 2;
- private static final int __TEMPORARY_ISSET_ID = 3;
- private static final int __REWRITEENABLED_ISSET_ID = 4;
- private static final int __WRITEID_ISSET_ID = 5;
- private static final int __ISSTATSCOMPLIANT_ISSET_ID = 6;
+ private static final int __ID_ISSET_ID = 0;
+ private static final int __CREATETIME_ISSET_ID = 1;
+ private static final int __LASTACCESSTIME_ISSET_ID = 2;
+ private static final int __RETENTION_ISSET_ID = 3;
+ private static final int __TEMPORARY_ISSET_ID = 4;
+ private static final int __REWRITEENABLED_ISSET_ID = 5;
+ private static final int __WRITEID_ISSET_ID = 6;
+ private static final int __ISSTATSCOMPLIANT_ISSET_ID = 7;
private byte __isset_bitfield = 0;
- private static final _Fields optionals[] = {_Fields.PRIVILEGES,_Fields.TEMPORARY,_Fields.REWRITE_ENABLED,_Fields.CREATION_METADATA,_Fields.CAT_NAME,_Fields.OWNER_TYPE,_Fields.WRITE_ID,_Fields.IS_STATS_COMPLIANT};
+ private static final _Fields optionals[] = {_Fields.ID,_Fields.PRIVILEGES,_Fields.TEMPORARY,_Fields.REWRITE_ENABLED,_Fields.CREATION_METADATA,_Fields.CAT_NAME,_Fields.OWNER_TYPE,_Fields.WRITE_ID,_Fields.IS_STATS_COMPLIANT};
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
+ tmpMap.put(_Fields.ID, new org.apache.thrift.meta_data.FieldMetaData("id", org.apache.thrift.TFieldRequirementType.OPTIONAL,
+ new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.TABLE_NAME, new org.apache.thrift.meta_data.FieldMetaData("tableName", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.DB_NAME, new org.apache.thrift.meta_data.FieldMetaData("dbName", org.apache.thrift.TFieldRequirementType.DEFAULT,
@@ -311,6 +319,7 @@ public Table(
*/
public Table(Table other) {
__isset_bitfield = other.__isset_bitfield;
+ this.id = other.id;
if (other.isSetTableName()) {
this.tableName = other.tableName;
}
@@ -370,6 +379,8 @@ public Table deepCopy() {
@Override
public void clear() {
+ setIdIsSet(false);
+ this.id = 0;
this.tableName = null;
this.dbName = null;
this.owner = null;
@@ -400,6 +411,28 @@ public void clear() {
this.isStatsCompliant = false;
}
+ public long getId() {
+ return this.id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ setIdIsSet(true);
+ }
+
+ public void unsetId() {
+ __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __ID_ISSET_ID);
+ }
+
+ /** Returns true if field id is set (has been assigned a value) and false otherwise */
+ public boolean isSetId() {
+ return EncodingUtils.testBit(__isset_bitfield, __ID_ISSET_ID);
+ }
+
+ public void setIdIsSet(boolean value) {
+ __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ID_ISSET_ID, value);
+ }
+
public String getTableName() {
return this.tableName;
}
@@ -889,6 +922,14 @@ public void setIsStatsCompliantIsSet(boolean value) {
public void setFieldValue(_Fields field, Object value) {
switch (field) {
+ case ID:
+ if (value == null) {
+ unsetId();
+ } else {
+ setId((Long)value);
+ }
+ break;
+
case TABLE_NAME:
if (value == null) {
unsetTableName();
@@ -1054,6 +1095,9 @@ public void setFieldValue(_Fields field, Object value) {
public Object getFieldValue(_Fields field) {
switch (field) {
+ case ID:
+ return getId();
+
case TABLE_NAME:
return getTableName();
@@ -1125,6 +1169,8 @@ public boolean isSet(_Fields field) {
}
switch (field) {
+ case ID:
+ return isSetId();
case TABLE_NAME:
return isSetTableName();
case DB_NAME:
@@ -1182,6 +1228,15 @@ public boolean equals(Table that) {
if (that == null)
return false;
+ boolean this_present_id = true && this.isSetId();
+ boolean that_present_id = true && that.isSetId();
+ if (this_present_id || that_present_id) {
+ if (!(this_present_id && that_present_id))
+ return false;
+ if (this.id != that.id)
+ return false;
+ }
+
boolean this_present_tableName = true && this.isSetTableName();
boolean that_present_tableName = true && that.isSetTableName();
if (this_present_tableName || that_present_tableName) {
@@ -1369,6 +1424,11 @@ public boolean equals(Table that) {
public int hashCode() {
List
-
-
-
-
+
+
+
+
diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
index 4937d9d861..959620ffce 100644
--- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
+++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java
@@ -220,6 +220,8 @@ private static void partitionTester(HiveMetaStoreClient client, Configuration co
// on the location being present in the 'tbl' object - so get the table
// from the metastore
tbl = client.getTable(dbName, tblName);
+ Assert.assertTrue(tbl.isSetId());
+ tbl.unsetId();
}
Partition part = makePartitionObject(dbName, tblName, vals, tbl, "/part1");
@@ -1272,6 +1274,7 @@ public void testSimpleTable() throws Exception {
Table tbl2 = client.getTable(dbName, tblName);
assertNotNull(tbl2);
+ Assert.assertTrue(tbl2.isSetId());
assertEquals(tbl2.getDbName(), dbName);
assertEquals(tbl2.getTableName(), tblName);
assertEquals(tbl2.getSd().getCols().size(), typ1.getFields().size());
@@ -1305,6 +1308,7 @@ public void testSimpleTable() throws Exception {
assertTrue(fieldSchemasFull.contains(fs));
}
+ tbl2.unsetId();
client.createTable(tbl2);
if (isThriftClient) {
tbl2 = client.getTable(tbl2.getDbName(), tbl2.getTableName());
@@ -1663,6 +1667,53 @@ public void testGetSchemaWithNoClassDefFoundError() throws TException {
client.getSchema(dbName, tblName);
}
+ @Test
+ public void testCreateAndGetTableWithDriver() throws Exception {
+ String dbName = "createDb";
+ String tblName = "createTbl";
+
+ client.dropTable(dbName, tblName);
+ silentDropDatabase(dbName);
+ new DatabaseBuilder()
+ .setName(dbName)
+ .create(client, conf);
+
+ createTable(dbName, tblName);
+ Table tblRead = client.getTable(dbName, tblName);
+ Assert.assertTrue(tblRead.isSetId());
+ long firstTableId = tblRead.getId();
+
+ createTable(dbName, tblName + "_2");
+ Table tblRead2 = client.getTable(dbName, tblName + "_2");
+ Assert.assertTrue(tblRead2.isSetId());
+ Assert.assertNotEquals(firstTableId, tblRead2.getId());
+ }
+
+ @Test
+ public void testCreateTableSettingId() throws Exception {
+ String dbName = "createDb";
+ String tblName = "createTbl";
+
+ client.dropTable(dbName, tblName);
+ silentDropDatabase(dbName);
+ new DatabaseBuilder()
+ .setName(dbName)
+ .create(client, conf);
+
+ Table table = new TableBuilder()
+ .setDbName(dbName)
+ .setTableName(tblName)
+ .addCol("foo", "string")
+ .addCol("bar", "string")
+ .build(conf);
+ table.setId(1);
+ try {
+ client.createTable(table);
+ Assert.fail("An error should happen when setting the id"
+ + " to create a table");
+ } catch (InvalidObjectException e) {}
+ }
+
@Test
public void testAlterTable() throws Exception {
String dbName = "alterdb";
diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java
index bf302ed491..a9312b8c1f 100644
--- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java
+++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/client/TestTablesCreateDropAlterTruncate.java
@@ -238,6 +238,9 @@ public void testCreateGetDeleteTable() throws Exception {
table.setParameters(createdTable.getParameters());
table.setCreationMetadata(createdTable.getCreationMetadata());
table.setWriteId(createdTable.getWriteId());
+
+ Assert.assertTrue(createdTable.isSetId());
+ createdTable.unsetId();
Assert.assertEquals("create/get table data", table, createdTable);
// Check that the directory is created
@@ -457,6 +460,7 @@ public void testCreateTableNoSuchDatabase() throws Exception {
@Test(expected = AlreadyExistsException.class)
public void testCreateTableAlreadyExists() throws Exception {
Table table = testTables[0];
+ table.unsetId();
client.createTable(table);
}
@@ -524,6 +528,7 @@ public void testDropTableCaseInsensitive() throws Exception {
// Expected exception
}
+ table.unsetId();
// Test in mixed case
client.createTable(table);
client.dropTable("DeFaUlt", "TeST_tAbLE");
@@ -546,6 +551,7 @@ public void testDropTableDeleteDir() throws Exception {
Assert.assertFalse("Table path should be removed",
metaStore.isPathExists(new Path(table.getSd().getLocation())));
+ table.unsetId();
client.createTable(table);
client.dropTable(table.getDbName(), table.getTableName(), false, false);
@@ -705,6 +711,9 @@ public void testAlterTable() throws Exception {
newTable.setCreateTime(alteredTable.getCreateTime());
newTable.setCreationMetadata(alteredTable.getCreationMetadata());
newTable.setWriteId(alteredTable.getWriteId());
+
+ Assert.assertTrue(alteredTable.isSetId());
+ alteredTable.unsetId();
Assert.assertEquals("The table data should be the same", newTable, alteredTable);
}