vihangk1 commented on a change in pull request #1737:
URL: https://github.com/apache/hive/pull/1737#discussion_r539546029



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands.java
##########
@@ -378,6 +378,33 @@ private IMetaStoreClient prepareParallelTest(String 
tableName, int val)
     return msClient;
   }
 
+  @Test
+  public void testAddConstraintAdvancingWriteIds() throws Exception {
+
+    String tableName = "constraints_table";
+    hiveConf.setBoolean("hive.stats.autogather", true);
+    hiveConf.setBoolean("hive.stats.column.autogather", true);
+    // Need to close the thread local Hive object so that configuration change 
is reflected to HMS.
+    Hive.closeCurrent();
+    runStatementOnDriver("drop table if exists " + tableName);
+    runStatementOnDriver(String.format("create table %s (a int, b string) 
stored as orc " +
+        "TBLPROPERTIES ('transactional'='true', 
'transactional_properties'='insert_only')",
+        tableName));
+    runStatementOnDriver(String.format("insert into %s (a) values (0)", 
tableName));
+    IMetaStoreClient msClient = new HiveMetaStoreClient(hiveConf);
+    String validWriteIds = msClient.getValidWriteIds("default." + 
tableName).toString();
+    LOG.info("ValidWriteIds before add constraint::"+ validWriteIds);
+    Assert.assertEquals("default.constraints_table:1:9223372036854775807::", 
validWriteIds);
+    runStatementOnDriver(String.format("alter table %s  ADD CONSTRAINT a_PK 
PRIMARY KEY (`a`) DISABLE NOVALIDATE", tableName));
+    validWriteIds  = msClient.getValidWriteIds("default." + 
tableName).toString();
+    LOG.info("ValidWriteIds after add constraint primary key::"+ 
validWriteIds);
+    Assert.assertEquals("default.constraints_table:2:9223372036854775807::", 
validWriteIds);
+    runStatementOnDriver(String.format("alter table %s CHANGE COLUMN b b 
STRING NOT NULL", tableName));
+    validWriteIds  = msClient.getValidWriteIds("default." + 
tableName).toString();

Review comment:
       Can we add the test for unique and check constraints as well for 
completeness?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to