You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Karimkhan Pathan <ka...@gmail.com> on 2016/01/15 10:58:51 UTC
Fwd: Using python for hive table quering gives error
I am trying to query hive table with basic example code:
*import pyhs2*
*with pyhs2.connect(host='dmet-master05.inetu.net
<http://dmet-master05.inetu.net>',*
* port=10000,*
* authMechanism='PLAIN',*
* user='karim',*
* password='karim',*
* database='default') as conn:*
* with conn.cursor() as cur:*
* #Show databases*
* print cur.getDatabases()*
* #Execute query*
* cur.execute("select * from user_data")*
* #Return column info from query*
* print cur.getSchema()*
* #Fetch table results*
* for i in cur.fetch():*
* print i*
* #break*
When I execute this script, it gives
*Traceback (most recent call last):*
* File "py_hive.py", line 8, in <module>*
* database='default') as conn:*
* File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/__init__.py", line
7, in connect*
* return Connection(*args, **kwargs)*
* File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/connections.py",
line 52, in __init__*
* cur.execute(query) *
* File "/home/karimk/python/lib/python2.7/site-packages/pyhs2/cursor.py",
line 61, in execute*
* res = self.client.ExecuteStatement(query)*
* File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/TCLIService/TCLIService.py",
line 244, in ExecuteStatement*
* return self.recv_ExecuteStatement()*
* File
"/home/karimk/python/lib/python2.7/site-packages/pyhs2/TCLIService/TCLIService.py",
line 260, in recv_ExecuteStatement*
* raise x*
*thrift.Thrift.TApplicationException: Required field 'sessionHandle' is
unset! Struct:TExecuteStatementReq(sessionHandle:null, statement:USE
default, confOverlay:{})*
Any help much appreciated.
--
Regards,
Karimkhan,
http://www.quora.com/Pathan-Karimkhan
https://www.facebook.com/karimkhan.it
http://in.linkedin.com/in/karimkhanp
Re: Using python for hive table quering gives error
Posted by Gopal Vijayaraghavan <go...@apache.org>.
> i could find all examples using pyhs2 only.
The pyhs2 site points to dropbox/pyhive.
But even that doesn't work for me unless I replace the TCLIService dir
with the one generated by thrift-0.9.2 (after HIVE-8829).
Maybe you might have better luck, depending on the exact version of
HiveServer2 you're using.
Cheers,
Gopal
Re: Using python for hive table quering gives error
Posted by Karimkhan Pathan <ka...@gmail.com>.
So what is the correct way to do this.
i could find all examples using *pyhs2 only.*
On Fri, Jan 15, 2016 at 3:40 PM, Gopal Vijayaraghavan <go...@apache.org>
wrote:
>
> > import pyhs2
>
> ...
> > thrift.Thrift.TApplicationException: Required field 'sessionHandle' is
> >unset! Struct:TExecuteStatementReq(sessionHandle:null, statement:USE
> >default, confOverlay:{})
>
> That's a version mismatch in the thrift protocol layer (JDBC to be
> precise).
>
> PyHS2 is deprecated and unmaintained.
>
> Cheers,
> Gopal
>
>
>
--
Regards,
Karimkhan,
http://www.quora.com/Pathan-Karimkhan
https://www.facebook.com/karimkhan.it
http://in.linkedin.com/in/karimkhanp
Re: Using python for hive table quering gives error
Posted by Gopal Vijayaraghavan <go...@apache.org>.
> import pyhs2
...
> thrift.Thrift.TApplicationException: Required field 'sessionHandle' is
>unset! Struct:TExecuteStatementReq(sessionHandle:null, statement:USE
>default, confOverlay:{})
That's a version mismatch in the thrift protocol layer (JDBC to be
precise).
PyHS2 is deprecated and unmaintained.
Cheers,
Gopal