kszucs / pandahouse

Pandas interface for Clickhouse database
MIT License
228 stars 70 forks source link

Provide support for Enum #23

Open zotttttttt opened 4 years ago

zotttttttt commented 4 years ago

Right now pandahouse throws this error when you're querying some column with enum value in it:

df = pdch.read_clickhouse(query, connection=connection)

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<timed exec> in <module>

~/anaconda3/lib/python3.6/site-packages/pandahouse/core.py in read_clickhouse(query, tables, index, connection, **kwargs)
     56     lines = execute(query, external=external, stream=True,
     57                     connection=connection)
---> 58     return to_dataframe(lines, **kwargs)
     59 
     60 

~/anaconda3/lib/python3.6/site-packages/pandahouse/convert.py in to_dataframe(lines, **kwargs)
     65     dtypes, parse_dates, converters = {}, [], {}
     66     for name, chtype in zip(names, types):
---> 67         dtype = CH2PD[chtype]
     68         if dtype == 'object':
     69             converters[name] = decode_escapes
KeyError: "Enum8(\\'one\\' = 1, \\'two\\' = 2)"

You can learn more about enum here (if you need it)