From 151d28cae43c715a56df67cfeecf889c85a359e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Kut=C3=BD?= <6du1ro.n@gmail.com> Date: Wed, 30 May 2018 09:43:16 +0200 Subject: [PATCH] Support types like varchar(255), try to recognize types. --- pyhive/sqlalchemy_presto.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pyhive/sqlalchemy_presto.py b/pyhive/sqlalchemy_presto.py index 8d6757a5..12427f64 100644 --- a/pyhive/sqlalchemy_presto.py +++ b/pyhive/sqlalchemy_presto.py @@ -144,11 +144,17 @@ def get_columns(self, connection, table_name, schema=None, **kw): rows = self._get_table_columns(connection, table_name, schema) result = [] for row in rows: + try: coltype = _type_map[row.Type] except KeyError: - util.warn("Did not recognize type '%s' of column '%s'" % (row.Type, row.Column)) - coltype = types.NullType + # try recognize + try: + coltype = row.Type.split("(")[0] + coltype = _type_map[coltype] + except (IndexError, KeyError): + util.warn("Did not recognize type '%s' of column '%s'" % (row.Type, row.Column)) + coltype = types.NullType result.append({ 'name': row.Column, 'type': coltype,