Search code examples
hadoophivehqlhortonworks-data-platformbigdata

Example about how set a Hive property from within a Hive query


I need a quick example of how to change a property in hive using a query, for instance, I would like to change the property 'mapred.reduce.tasks' so, how to perform this change within a query.

I'm training my self for HDPCD exam and one of the goals in the exam is 'Set a Hadoop or Hive configuration property from within a Hive query' So I suppose that it's not the same as performing in hive console something like:

set mapred.reduce.tasks=2;

Solution

  • To change Hadoop and Hive configuration variable you need to use set in the hive query. The change made will be applicable only to that query session

    set -v prints all Hadoop and Hive configuration variables.

    SET mapred.reduce.tasks=XX // In Hadoop 1.X
    SET mapreduce.job.reduces=XX // In Hadoop 2.X (YARN)
    

    reset in query resets the configuration to the default values