zhangbutao commented on code in PR #6222:
URL: https://github.com/apache/hive/pull/6222#discussion_r2584755890


##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/HiveLockObject.java:
##########
@@ -212,35 +212,36 @@ public HiveLockObject(DummyPartition par, 
HiveLockObjectData lockData) {
   }
 
   /**
-   * Creates a locking object for a table (when partition spec is not provided)
+   * Creates a locking object for a database or table (when partition spec is 
not provided)
    * or a table partition
    * @param hiveDB    an object to communicate with the metastore
    * @param tableName the table to create the locking object on
    * @param partSpec  the spec of a partition to create the locking object on
    * @return  the locking object
    * @throws HiveException
    */
-  public static HiveLockObject createFrom(Hive hiveDB, String tableName,
+  public static HiveLockObject createFrom(Hive hiveDB, String dbName, String 
tableName,
       Map<String, String> partSpec) throws HiveException {
-    Table  tbl = hiveDB.getTable(tableName);
-    if (tbl == null) {
-      throw new HiveException("Table " + tableName + " does not exist ");
-    }
+    if (tableName != null) {
+      Table tbl = hiveDB.getTable(tableName);
+      if (tbl == null) {
+        throw new HiveException("Table " + tableName + " does not exist");
+      }
 
-    HiveLockObject obj = null;
+      if (partSpec == null) {
+        return new HiveLockObject(tbl, null);
+      }
 
-    if  (partSpec == null) {
-      obj = new HiveLockObject(tbl, null);
-    }
-    else {
       Partition par = hiveDB.getPartition(tbl, partSpec, false);
       if (par == null) {
-        throw new HiveException("Partition " + partSpec + " for table " +
-            tableName + " does not exist");
+        throw new HiveException("Partition " + partSpec + " for table " + 
tableName + " does not exist");
       }
-      obj = new HiveLockObject(par, null);
+      return new HiveLockObject(par, null);
+    } else if (dbName != null) {
+      return new HiveLockObject(dbName, null);
     }
-    return obj;
+
+    return null;

Review Comment:
   No need. Because returning null means matching all locks, and null is a 
valid return value.



-- 
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.

To unsubscribe, e-mail: [email protected]

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