Configuring custom Hive JDBC arguments

Learn how to configure Sqoop to enable users to specify custom Hive JDBC arguments while importing data into Hive using Sqoop. This allows users to set Hive session variables, Hive configuration values, and Hive user variables.

You can configure the required property either through Cloudera Manager or by using the --jdbc-arg argument in your Sqoop import command. Use the hiveconf: prefix to specify Hive configuration values and the hivevar: prefix to specify Hive user variables.
Order of precedence
The configuration set through the Sqoop argument in the command line takes precedence over the configuration specified through Cloudera Manager. If custom Hive JDBC arguments are specified through both the command line and Cloudera Manager, the command line Sqoop argument does not entirely overwrite the Cloudera Manager configuration. Instead, the distinct values are retained and the values with matching keys are replaced with arguments specified through the command line Sqoop argument.
  1. If you are specifying the custom Hive JDBC arguments through Cloudera Manager, perform the following steps:
    1. In Cloudera Manager, click Clusters and then select the SQOOP_CLIENT-1 service.
    2. From the Sqoop service, go to the Configuration tab and search for sqoop.hive-jdbc-params.
    3. Click and specify the custom Hive JDBC argument and its value.

      Configuring custom Hive JDBC arguments for Sqoop Hive import
    4. Click Save Changes.
  2. If you are specifying the custom Hive JDBC arguments through the Sqoop argument, specify the required key-value pair using the --hive-jdbc-arg argument while constructing the Sqoop import command.
    /opt/cloudera/parcels/CDH/bin/sqoop import \
      -Dsqoop.beeline.env.preserve=KRB5CCNAME \
      --connection-manager org.apache.sqoop.manager.MySQLManager \
      --connect jdbc:mysql://db.foo.com:3306/employees \
      --username [***USERNAME***] \
      --password [***PASSWORD***] \
      --table employees \
      --warehouse-dir /user/hrt_qa/test-sqoop \
      --hive-import \
      --delete-target-dir \
      --hive-overwrite \
      --hs2-url "jdbc:hive2://[***HOST***]:[***PORT***];serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2;transportMode=http;httpPath=cliservice;ssl=true;sslTrustStore=[***TRUSTSTORE PATH***];trustStorePassword=[***TRUSTSTORE PASSWORD***]" \
      --hive-jdbc-arg user=username \
      --hive-jdbc-arg hiveconf:hive.execution.engine=tez \
      --hive-jdbc-arg hivevar:tablename=mytable