PyHive icon indicating copy to clipboard operation
PyHive copied to clipboard

Support for complex types

Open john-bodley opened this issue 8 years ago • 7 comments

I was wondering why PyHive doesn't support complex types like ARRAY, MAP, STRUCT, etc?

john-bodley avatar May 16 '17 23:05 john-bodley

Not sure what you're requesting. Complex types work: https://github.com/dropbox/PyHive/blob/master/pyhive/tests/test_hive.py#L41

Are you asking for support for parsing the result strings into something nicer?

jingw avatar Jul 08 '17 05:07 jingw

Apologies @jingw I meant for Presto. I was looking at sqlalchemy_presto.py and didn't notice any, but per the Presto equivalent link you provided it seems like they are mentioned in test_presto.py.

john-bodley avatar Jul 17 '17 02:07 john-bodley

@jingw We are also seeing this with hive, querying a struct in hive returns as a string. https://github.com/dropbox/PyHive/blob/master/pyhive/sqlalchemy_hive.py#L98 Was trying to use it through superset's sqllab and found that we cant query fields inside a struct.

josephfrancis avatar Aug 01 '17 22:08 josephfrancis

@jingw I'm interested in getting this working at the very least for presto. I'm happy to make a PR if you have any suggestions on how best to represent the complex types in the current response format.

josephfrancis avatar Aug 05 '17 00:08 josephfrancis

If you meant Presto, that currently returns a struct as a list: https://github.com/dropbox/PyHive/blob/master/pyhive/tests/test_presto.py#L76

If you meant Hive, that returns strings: https://github.com/dropbox/PyHive/blob/master/pyhive/tests/test_hive.py#L65 We could add a flag parse_complex_types to the connection object (default false for compatibility) and have it return something similar to Presto. Sadly the return format isn't JSON compatible, but it looks like ast.literal_eval could be good enough. Need to check on what happens with fancier types like unicode characters and binary.

I'm not sure what you meant by linking to sqlalchemy_presto.py#L137

jingw avatar Aug 09 '17 02:08 jingw

There is a PR pending, waiting for over a week. Much frustrating.

kakipipi23 avatar May 31 '20 11:05 kakipipi23

This is quite a limitation for us. Any chance that hive returns a struct as list or similar?

panoptikum avatar May 28 '21 07:05 panoptikum