@Override
  public ObjectInspector initialize(ObjectInspector[] arguments) throws UDFArgumentException {
    if (arguments.length != 0) {
      throw new UDFArgumentLengthException(
          "The function CurrentAuthorizer does not take any arguments, but found " + arguments.length);
    }

    if (authorizer == null) {

      HiveConf hiveConf = SessionState.getSessionConf();
      HiveAuthorizer hiveAuthorizer = SessionState.get().getAuthorizerV2();
      try {
        if (hiveAuthorizer.getHivePolicyProvider() != null) {
          authorizer = new Text(hiveAuthorizer.getHivePolicyProvider().getClass().getSimpleName());
        }
      } catch (HiveAuthzPluginException e) {
        LOG.warn("Error getting HivePolicyProvider", e);
      }

      if (authorizer == null) {
        // If authorizer is not set, check for metastore authorizer (eg. StorageBasedAuthorizationProvider)
        if (MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.PRE_EVENT_LISTENERS) != null &&
            !MetastoreConf.getVar(hiveConf, MetastoreConf.ConfVars.PRE_EVENT_LISTENERS).isEmpty() &&
            HiveConf.getVar(hiveConf, HiveConf.ConfVars.HIVE_METASTORE_AUTHORIZATION_MANAGER) != null) {
          List<HiveMetastoreAuthorizationProvider> authorizerProviders;
          try {
            authorizerProviders = HiveUtils.getMetaStoreAuthorizeProviderManagers(
              hiveConf, HiveConf.ConfVars.HIVE_METASTORE_AUTHORIZATION_MANAGER,
              SessionState.get().getAuthenticator());
            for (HiveMetastoreAuthorizationProvider authProvider : authorizerProviders) {
              if (authProvider.getHivePolicyProvider() != null) {
                authorizer = new Text(authProvider.getHivePolicyProvider().getClass().getSimpleName());
                break;
              }
            }
          } catch (HiveAuthzPluginException e) {
            LOG.warn("Error getting HivePolicyProvider", e);
          } catch (HiveException e) {
            LOG.warn("Error instantiating hive.security.metastore.authorization.manager", e);
          }
        }
      }
    }

    return PrimitiveObjectInspectorFactory.writableStringObjectInspector;
  }
UDF to determine the current authorizer (class name of the authorizer)
This is intended for internal usage only. This function is not a deterministic function,
but a runtime constant. The return value is constant within a query but can be different between queries
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFCurrentAuthorizer.java