Pivotal Knowledge Base

Follow

Hive Query from Tableau failed with error Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

Problem:

Query from Tableau against hive external table pulling data from hbase fails, however regular tables with hive can be queried successfully from Tableau. All queries executed directly from a hive client on the cluster node works irrespective if its a external table or regular table.

On Tableau, you can see an error similar to the below which is a generic error.

Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask 

Further review of /var/log/gphd/hive/hive.log can indicate class not found exceptions similar to the below. The below lists all the exception which were encountered while setting up Tableau connection with hive external tables based on hbase.

Exception 1:

Error: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.mapreduce.TableSplit
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

Exception 2:

Error: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.client.HTable
        at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)

Exception 3:

Error: java.io.IOException: java.io.IOException: java.lang.reflect.InvocationTargetException
	at org.apache.hadoop.hive.io.HiveIOExceptionHandlerChain.handleRecordReaderCreationException(HiveIOExceptionHandlerChain.java:97)

...
...
Caused by: java.lang.ClassNotFoundException: org.cloudera.htrace.Trace
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)

Exception 4:

Error: java.lang.ClassNotFoundException: org.apache.hadoop.hbase.protobuf.generated.MasterProtos$MasterService$BlockingInterface
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 

Cause:

Integration of hive with hbase requires all the required hbase classes to be available in hive classpath. Auxiliary jar path setup in /etc/gphd/hive/conf/hive-env.sh is not visible to Tableau initiated connections and even if it's set you will see the above errors. You must set the hive.aux.jars.path parameter in hive-site.xml for the required jars to be located while querying from Tableau.

Other queries on regular hive tables from Tableau will work since the required jars have already been sourced.

In case, there are other similar class not found exception you need to add the respective classes to hive.aux.jars.path in hive-site.xml 

Fix:

Add the below parameters to /etc/gphd/hive/conf/hive-site.xml on hive-server. hive-server restart is not required.

<property>
<name>hive.aux.jars.path</name>
<value>file:///usr/lib/gphd/hbase/lib/hbase-server.jar,file:///usr/lib/gphd/hbase/lib/hbase-client.jar,file:///usr/lib/gphd/hbase/lib/hbase-protocol.jar,file:///usr/lib/gphd/hbase/lib/htrace-core-2.01.jar</value>
</property>

The below provides the mapping of the classes and their respective jars

Class Name Jar Name
TableSplit hbase-server.jar
HTable hbase-client.jar
MasterProtos hbase-protocol.jar
org.cloudera.htrace.Trace htrace-core-2.01.jar

Comments

Powered by Zendesk