Sure, go ahead.

To confirm, you'd like to submit a bug-fix PR as well, right? I started looking 
into it, and I think a quick fix might look like:

  private HiveLock lockObject(org.apache.hadoop.hive.metastore.api.Table 
hmsTable) {
    if (hiveLockEnabled(hmsTable, conf)) {
      return new MetastoreLock(
          conf, 
          new CachedClientPool(conf, Maps.fromProperties(catalogProperties)),
          catalogProperties.getProperty(Catalogs.NAME), 
          hmsTable.getDbName(), 
          hmsTable.getTableName());
    } else {
      return new NoLock();
    }
  }

  private static boolean 
hiveLockEnabled(org.apache.hadoop.hive.metastore.api.Table hmsTable, 
Configuration conf) {
    if (SessionStateUtil.getQueryState(conf).map(QueryState::getHiveOperation)
          .filter(opType -> HiveOperation.ANALYZE_TABLE == opType)
          .isPresent()) {
      return false;
    }

    if 
(hmsTable.getParameters().containsKey(TableProperties.HIVE_LOCK_ENABLED)) {
      // We know that the property is set, so default value will not be used,
      return Boolean.parseBoolean(
        
hmsTable.getParameters().getOrDefault(TableProperties.HIVE_LOCK_ENABLED, 
"false"));
    }

    return conf.getBoolean(
      ConfigProperties.LOCK_HIVE_ENABLED, 
TableProperties.HIVE_LOCK_ENABLED_DEFAULT);
  }

Reply via email to