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. Mapping user, group, or application entities to a pool routes queries from those entities to the pool. The queries in the pool are under workload management.

User or group mapping

As administrator, you can configure valid non-application mapping for a particular user or group. The pool must exist. Alternatively, you can 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.

Workload management bases authorization to fetch a group or user on the HDFS group configuration on the cluster. By default, these are Apache Hadoop users and groups, but you can configure Lightweight Directory Protocol (LDAP) and other mechanisms.

Application mapping

To create a mapping based on an application, you use one of the following designations:

  • The applicationName property in the JDBC connection string
  • using the SetClientInfo JDBC API with the ApplicationName key.

To configure explicit querying of any pool, use multiple mappings through the wmPool property in the JDBC connection string.

Unmanaged queries

Queries from users, groups, or applications not mapped to a pool are unmanaged. The queries are not under workload management.

Ordered rules

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.