Search code examples
pythoncloudera-cdhimpala

Impyla error when port is specified


I am using impyla 0.9.0, if I specify port in the connect

conn = impala.dbapi.connect(host='n1', port=21000)

I will get the following error

Traceback (most recent call last):
  File "./myquery.py", line 78, in <module>
    main(len(sys.argv), sys.argv)
  File "./myquery.py", line 58, in main
    cur = conn.cursor()
  File "/usr/lib/python2.6/site-packages/impala/dbapi/hiveserver2.py", line 55, in cursor
    rpc.open_session(self.service, user, configuration))
  File "/usr/lib/python2.6/site-packages/impala/_rpc/hiveserver2.py", line 132, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python2.6/site-packages/impala/_rpc/hiveserver2.py", line 214, in open_session
    resp = service.OpenSession(req)
  File "/usr/lib/python2.6/site-packages/impala/_thrift_gen/TCLIService/TCLIService.py", line 175, in OpenSession
    return self.recv_OpenSession()
  File "/usr/lib/python2.6/site-packages/impala/_thrift_gen/TCLIService/TCLIService.py", line 191, in recv_OpenSession
    raise x
thrift.Thrift.TApplicationException: Invalid method name: 'OpenSession'

But it is a valid port.

impala-shell -i n1:21000
Starting Impala Shell without Kerberos authentication
Connected to n1:21000
Server version: impalad version 2.1.1-cdh5 RELEASE (build 7901877736e29716147c4804b0841afc4ebc9037)
Welcome to the Impala shell. Press TAB twice to see a list of available commands.

Copyright (c) 2012 Cloudera, Inc. All rights reserved.

(Shell build version: Impala Shell v2.1.1-cdh5 (7901877) built on Tue Jan 27 16:23:42 PST 2015)
[n1:21000] >

Once I remove the port

conn = impala.dbapi.connect(host='n1')

It works again.


Solution

  • Impyla is trying to connect to Impala using the HiveServer2 protocol, so you should be using port 21050. Port 21000 is for the Beeswax protocol (which the Impala shell uses).