Apache Hive workload management commands
Also available as:
PDF

CREATE MAPPING

You create a mapping that automatically routes queries to a specific pool using this command.

CREATE MAPPING syntax

CREATE { USER | GROUP | APPLICATION } MAPPING 'entity_name' IN plan_name { TO pool_path | UNMANAGED } [ WITH ORDER num ]
      
  • entity_name

    A JDBC connection user, group of JDBC connection users, or JDBC application name

  • plan_name

    The resource plan name

  • pool_path

    The hierarchy of query pool names, in dot notation

  • num

    An integer

CREATE MAPPING examples

CREATE GROUP MAPPING 'students' IN rp1 TO pool1 WITH ORDER 1
CREATE GROUP MAPPING 'teachers' IN rp1 TO pool2 WITH ORDER 3
CREATE APPLICATION MAPPING 'app1' IN rp1 TO pool3 WITH ORDER 2
Assuming the default pool is pool4, the following mapping occurs:
  • Queries from users in group students go to pool1.
  • Users using app1 go to pool2, unless they are in group students.
  • Users in group teacher go to pool3, unless they are also in group students or are using app1.
  • Users that are not in students or teachers and that are not using application app1 go to pool4.

CREATE MAPPING description

You can create a mapping based on a user, a group, or an application identified by the entity name. A group is fetched according to the HDFS groups configuration on the cluster. By default, these are Apache Hadoop groups, but you can configure Lightweight Directory Protocol (LDAP) and other mechanisms. An application name is defined by the applicationName property in the JDBC connection string, or by using the SetClientInfo JDBC API with the ApplicationName key.

Mapping user, group, or application entities to a pool routes queries from those entities to a pool. The queries in the pool are under workload management. Queries from users, groups, or applications not mapped to a pool are unmanaged. The queries are not under workload management. To configure explicit querying of any pool, use multiple mappings through the wmPool property in the JDBC connection string. As administrator, you must configure valid non-application mapping for a user and the pool must exist, or you must set hive.server2.wm.allow.any.pool.via.jdbc to true. For example, users in two different groups, each mapped to a separate pool, can explicitly submit queries to either of the pools regardless of the priority of the corresponding mappings that apply.

The optional WITH ORDER clause establishes the priorities for the rules. If multiple rules apply (for example, a user rule and a group rule, or multiple groups), the lowest ordered rule takes precedence. If ordering is not specified (or is the same), user rules take precedence over application rules, which take precedence over group rules. The order of group rules with the same priority is undefined.