superset icon indicating copy to clipboard operation
superset copied to clipboard

Connecting Superset to Kerberized Hive with Pyhive

Open Oswfrans opened this issue 9 years ago • 8 comments

I am trying to connect a kerberized Hive instance with superset and am running in to some issues, not sure if this should be tagged a question.

  • [x] I have checked the superset logs for python stacktraces and included it here as text if any
  • [x] I have reproduced the issue with at least the latest released version of superset
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar

Superset version 0.17.6

Pyhive version 0.3.0 Python version 2.7.5 Thrift version 0.10.0 Thrift Sasl version latest

Expected results

Successful connection of the Kerberized hive with superset

Actual results

error TSocket read 0 bytes

Steps to reproduce

First start the server on which superset is running and kinit there with the correct keytabs: kinit before starting superset Next go to superset and to add database Try the following URI: hive://xxx.xx.xx:port/databasename?auth=KERBEROS&kerberos_service_name=hive Also tried: hive://host:10000/database;AuthMech=1;KrbRealm=MY-REALM;KrbHostFQDN=host;KrbServiceName=hive

Where host / xxx.xx.xx are the hostname of HiveServer2

Test connection -> error ensues

Any help would be greatly appreciated.

Oswfrans avatar May 30 '17 11:05 Oswfrans

Can you get pyhive/sqlalchemy to connect on its own with that connection string?

mistercrunch avatar May 30 '17 16:05 mistercrunch

Hi Mistercrunch thank you for the suggestion. I tried the following code on the server where superset is installed in both the general python shell and the superset shell, after a kinit.

from sqlalchemy import *
from sqlalchemy.engine import create_engine
from sqlalchemy.schema import *
# Hive
engine = create_engine('hive://localhost:10000/default', connect_args={'auth': 'KERBEROS', 
'kerberos_service_name': 'hive'})
logs = Table('my_awesome_data', MetaData(bind=engine), autoload=True)
print select([func.count('*')], from_obj=logs).scal

sadly in both instances we get the same failure. End of the stacktrace:

    File "/var/venv/lib/python2.7/site-packages/thrift/transport/TSocket.py", line 132, in read
     message='TSocket read 0 bytes')
     TTransportException: TSocket read 0 bytes

Not sure where the issue is located, any further direction or help would be more than welcome.

Oswfrans avatar May 31 '17 08:05 Oswfrans

@Oswfrans have you tried googling the error?

xrmx avatar May 31 '17 09:05 xrmx

I know that for Airflow (another project I work on) we moved away from PyHive and into using Cloudera's Impyla to support Kerberized Hive since PyHive didn't support it at the time. In that case we do not use SQLAlchemy.

I think Impyla has issues with DBAPI compliance that make it incompatible with SQLAlchemy.

So. Two solution paths that are external to Superset:

  • figure out how to Kerberize PyHive
  • figure out how to SQLAlchemize Impyla

We're not the first people to attempt this, so there are related Github issues in the wild. If you do some research please paste your findings in this issue. Airbnb is interested as we're starting to think about Kerberize our cluster(s).

Latest I researched both solutions had shortcomings but seemed on the verge of breaking through.

mistercrunch avatar May 31 '17 16:05 mistercrunch

Hi all,

Connecting via PyHive to a Kerberized Hive should now be possible per this merged pull request and this stack overflow answer. The PyHive change at least seems to work on a toy cluster.

However, the problem in our case seems to be that our production HiveServer2 is set to http mode to support other services, while it needs to be set to binary. There is an open Jira request to enable Hive to allow both http mode and binary mode simultaneously and there is an open PyHive issue to support http for PyHive. Current workaround is to setup another HiveServer2 instance.

Will close the issue and consider setting up Druid to connect to superset. Thank you for the help!

Oswfrans avatar Jun 01 '17 11:06 Oswfrans

Note that Hive won't provide a good experience with Superset as it's just way to slow for most interactive use cases. At Airbnb we use Hive with SQL Lab, mainly to create summary datasets that we'll then query through Presto from the explore view.

mistercrunch avatar Jun 01 '17 16:06 mistercrunch

@mistercrunch . When you say Hive doesn't provide a good experience with Superset, do you mean the native MapReduce or the Hive LLAP ?

SanjayJosh avatar Feb 07 '18 09:02 SanjayJosh

MR Hive just because it's so slow. Haven't used LLAP Hive.

mistercrunch avatar Feb 07 '18 16:02 mistercrunch