superset icon indicating copy to clipboard operation
superset copied to clipboard

SQLAlchemy URI to connect to a Presto Database with LDAP authentication.

Open SanjayJosh opened this issue 8 years ago • 4 comments

Make sure these boxes are checked before submitting your issue - thank you!

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

Superset version

Superset 0.22.1 on Mac OSX

I want to know the structure of the SQLAlchemy URI to add a Presto Database that requires an LDAP authentication. I have tried various ways - presto://username:password@hostname:8080/catalog/schema

presto://username:password@hostname:8443/catalog/schema with extra parameters as connect_args { 'auth':'LDAP' } and / or { 'protocol':'https' }

However I get an error alert box on 'test connection' saying "ERROR. Refused to connect to the hostname. Please do let me know what the problem could be.

SanjayJosh avatar Feb 16 '18 10:02 SanjayJosh

Have you really looked for python stacktraces in your logs?

xrmx avatar Feb 16 '18 10:02 xrmx

For presto://username:password@hostname:8080/catalog/schema

the stack python stack trace is:


Traceback (most recent call last):
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/superset/views/core.py", line 1508, in testconn
    return json_success(json.dumps(engine.table_names(), indent=4))
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 2128, in table_names
    return self.dialect.get_table_names(conn, schema)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/pyhive/sqlalchemy_presto.py", line 193, in get_table_names
    return [row.Table for row in connection.execute(query)]
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 939, in execute
    return self._execute_text(object, multiparams, params)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1097, in _execute_text
    statement, parameters
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1189, in _execute_context
    context)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1405, in _handle_dbapi_exception
    util.reraise(*exc_info)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/base.py", line 1182, in _execute_context
    context)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/sqlalchemy/engine/default.py", line 470, in do_execute
    cursor.execute(statement, parameters)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/pyhive/presto.py", line 205, in execute
    url, data=sql.encode('utf-8'), headers=headers, **self._requests_kwargs)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 513, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/requests/sessions.py", line 623, in send
    r = adapter.send(request, **kwargs)
  File "/Users/s0j00os/anaconda3/lib/python3.6/site-packages/requests/adapters.py", line 504, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='hostname', port=8080): Max retries exceeded with url: /v1/statement (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x1094b8cf8>: Failed to establish a new connection: [Errno 60] Operation timed out',))

I have already tried running a presto client on the worker presto node directly, and that works fine. My guess is that I need the right URI format to also somehow add in the LDAP authentication of the Database.

Also, I had given the right hostname . I replaced that value for security reasons. 😄

SanjayJosh avatar Feb 16 '18 14:02 SanjayJosh

Looking quickly at the PyHive library, I don't see any LDAP support for Presto. The first step would be to get PyHive to connect through LDAP.

Looks like PyHive and Impyla have some support for LDAP connection to Hive though.

mistercrunch avatar Feb 19 '18 00:02 mistercrunch

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

stale[bot] avatar Apr 11 '19 02:04 stale[bot]