Presto Integration with Hue

I am deploying Hue-4.4.
I wanted to know that, if currently Hue supports connector to presto ?

There are some connectors https://docs.gethue.com/latest/administrator/configuration/editor/#presto

Hi Romain,

Thanks for the link.

As per the link. I can see that presto connector is available.
When I tried to add the configuration in hue.ini and re run HUE.
On clicking the Editor -> Presto button I am getting the following error.

An error occurred while calling z:java.sql.DriverManager.getConnection. : java.sql.SQLException: Authentication using username/password requires SSL to be enabled at com.facebook.presto.jdbc.PrestoDriverUri.setupClient(PrestoDriverUri.java:160) at com.facebook.presto.jdbc.PrestoDriver.connect(PrestoDriver.java:90) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) …l.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:231) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:381) at py4j.Gateway.invoke(Gateway.java:259) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:133) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:209) at java.lang.Thread.run(Thread.java:748)

It is asking for SSL to be enabled. But I don’t want to user SSL.
Is there a way to integrate presto in Hue with SSL being disabled?

Thanks Again.

Could you use the SqlAlchemy interface and not JDBC?

This is the most used one:

The dialect should be added to the Python system or Hue Python virtual environment:

  ./build/env/bin/pip install pyhive

Then give Hue the information about the database source:

[[[presto]]]
   name = Presto
   interface=sqlalchemy
   options='{"url": "presto://localhost:8080/hive/default"}'

@Romain i used SqlAlchemy interface , but when i am running query in presto editor its running the query as the user by which hue is running and not as end user.
Hence i am getting permission issues on hdfs.

am i missing anything?

Thanks

I see, I guess we would need to patch the sqlalchemy interface to allow setting a principal: https://github.com/dropbox/PyHive/pull/309/files

Hi @Romain,

I already have this patch in my pyhive/presto.py file.
still impersonation is not happening and queries are not running with end user.
queries are running with the user by which hue process is running

Yes, https://github.com/cloudera/hue/blob/master/desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py#L148 might need to be changed to allow to propagate it.

What do you specify for the connection URL?

Hi @Romain,

I copied the above sql_alchemy.py and replaced it with my sql_alchemy.py file.
still the queries are not executing with end user.

This is my connection url.

[[[presto]]]
name=Presto
interface=sqlalchemy
options=’{“url”: “presto://xxxx:8285/hive/default”}’

Want to try https://issues.cloudera.org/browse/HUE-9270 ?

@Romain,

Thanks for this suggestion. I applied this patch on 4.6 version manually and now impersonation in presto is working .
Thanks again.

1 Like

@Romain/@kush
I see Hue-9270 is fixed in 4.8. However, from the gethue website, this feature is available in 4.7.1 as well(We are using docker image of this on K8s). Without impersonation & LDAP disabled Presto, I am able to query from Hue. However, when LDAP is enabled for Presto service and making use of hasImpersonation option in hue, hue throws the following error:

[05/Aug/2020 16:58:40 -0700] access INFO 127.0.0.1 test - “POST /notebook/api/autocomplete/ HTTP/1.1” return
ed in 94ms 200 602
[05/Aug/2020 16:59:01 -0700] presto INFO SHOW SCHEMAS
[05/Aug/2020 16:59:01 -0700] decorators ERROR Error running autocomplete
Traceback (most recent call last):
File “/usr/share/hue/desktop/libs/notebook/src/notebook/decorators.py”, line 114, in wrapper
return f(*args, **kwargs)
File “/usr/share/hue/desktop/libs/notebook/src/notebook/api.py”, line 729, in autocomplete
autocomplete_data = get_api(request, snippet).autocomplete(snippet, database, table, column, nested, action)
File “/usr/share/hue/desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py”, line 105, in decorator
raise e
OperationalError: (pyhive.exc.OperationalError) Unexpected status code 403

Error 403 Forbidden

HTTP ERROR 403 Forbidden

URI: /v1/statement
STATUS: 403
MESSAGE: Forbidden
SERVLET: org.glassfish.jersey.servlet.ServletContainer-328e50eb
[SQL: SHOW SCHEMAS] (Background on this error at: http://sqlalche.me/e/e3q8)

Any help in mitigating this error please? We are currently blocked accessing Presto.

Thanks.
Rav

How did you specify the LDAP credentials?

Hi @Romain/@kush ,

Thanks for responding. Our Presto cluster is SSL LDAP enabled, so configured it like below in Notebook section:

Case-1:
[[[presto]]]
interface=sqlalchemy
name=Presto
options=’{“url”: “presto://user:password@presto-corrdinator:8443/hive/dwh”}’
In the above case, below is the exception in hue logs:

(exceptions.ValueError) Protocol must be https when passing a password [SQL: SHOW SCHEMAS]

Case-2:
[[[presto]]]
interface=sqlalchemy
name=Presto
options=’{“url”: “presto://username:password@https://presto coordinator:8443/hive/dwh”}’

In this case, following is the error:

ValueError: invalid literal for int() with base 10: ‘’
[14/Aug/2020 10:59:28 -0700] decorators ERROR Error running autocomplete
Traceback (most recent call last):
File “/usr/share/hue/desktop/libs/notebook/src/notebook/decorators.py”, line 114, in wrapper
return f(*args, **kwargs)
File “/usr/share/hue/desktop/libs/notebook/src/notebook/api.py”, line 729, in autocomplete
autocomplete_data = get_api(request, snippet).autocomplete(snippet, database, table, column, nested)
File “/usr/share/hue/desktop/libs/notebook/src/notebook/connectors/sql_alchemy.py”, line 113, in decorator
raise QueryError(message)
QueryError: invalid literal for int() with base 10: ‘’

Is this a bug in Hue? Let me know if you want me to file an issue. This is currently blocking me to use Hue.

For others to refer, Presto LDAPS over HTTPS was discussed in https://github.com/cloudera/hue/issues/1246 & resolved in: https://github.com/cloudera/hue/pull/1249