2

I want to connect presto using pyhive in zeppelin

now, I follows about https://github.com/dropbox/PyHive

I use the connect function and correct parameters.

%python
from pyhive import presto
cursor =  presto.connect(host='localhost',
                port=10000,
                username='id:password').cursor()
cursor.execute('SELECT * FROM table LIMIT 10')

but it does not work.

Traceback (most recent call last):
  File "/tmp/zeppelin_python-557261260901431465.py", line 278, in <module>
    raise Exception(traceback.format_exc())
Exception: Traceback (most recent call last):
  File "/tmp/zeppelin_python-557261260901431465.py", line 266, in <module>
    exec(code)
  File "<stdin>", line 5, in <module>
  File "/usr/lib/python2.7/dist-packages/pyhive/presto.py", line 206, in execute
    self._process_response(response)
  File "/usr/lib/python2.7/dist-packages/pyhive/presto.py", line 263, in _process_response
    response_json = response.json()
  File "/usr/lib/python2.7/dist-packages/requests/models.py", line 650, in json
    return json.loads(self.content.decode(encoding), **kwargs)
  File "/usr/lib64/python2.7/encodings/utf_32_le.py", line 11, in decode
    return codecs.utf_32_le_decode(input, errors, True)
UnicodeDecodeError: 'utf32' codec can't decode bytes in position 4-7: code point not in range(0x110000)

how can I fix it?

Arghavan
  • 1,125
  • 1
  • 11
  • 17
lil
  • 439
  • 3
  • 8
  • 17

2 Answers2

0

Did you try to separate username and password? presto.connect(host='xxx', port=xxx, username='xxx', password='xxx')worked for me.

  • i can find a anwser ! i wrong the port .. username ='id:password' is right!~ – lil Sep 20 '17 at 05:14
  • The problem here is character encoding - somewhere you have `utf32 little endian` set and it is having a problem decoding the data returned. Try setting this to `utf-8` or something else. – Tim May 07 '19 at 18:19
0

My Connection looks like:

presto.connect(host=url, port=port_num, protocol='https', username=user, password=pass)

Of note, port is a str, not an int in my input.

BeRT2me
  • 12,699
  • 2
  • 13
  • 31