You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2020/12/09 18:46:34 UTC

[GitHub] [hive] vihangk1 commented on a change in pull request #1737: Set advanced write Id during add constraint DDL tasks

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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org