Search code examples
oozie

How to supply hiveconf variable from hive oozie action


I want to supply variable as hiveconf namespace from my hive-oozie action, how to do that?

<action name="setupAct">
  <hive xmlns="uri:oozie:hive-action:0.2">
    <job-tracker>maprfs:///</job-tracker>
    <name-node>maprfs:///</name-node>
    <script>
      XYZ.hql
    </script>
    <!--how to add variable to hiveconf-->
    <param>DB_NAME=test</param>
  </hive>
  <ok to="ok" />
  <error to="error" />
</action>

The values inside param element are supplied as --hivevar namespace to hive.

Below is application log, the param element gets added as hivevar:

------------------------
  DB_NAME=test
------------------------
Hive command arguments :
      --hivevar
        DB_NAME=test
        -f
         test.hql

Solution

  • For hiveconf in Oozie, Use the configuration element.

    <hive xmlns="uri:oozie:hive-action:0.2">
        <job-tracker>maprfs:///</job-tracker>
        <name-node>maprfs:///</name-node>
        <script>
          XYZ.hql
        </script>
        <!--how to add variable to hiveconf-->
        <configuration>
           <property>
              <name>hive.default.fileformat</name>
              <value>Parquet</value>
           </property>
        </configuration>
        <param>DB_NAME=test</param>
      </hive>