heavyai/pymapd

get_table_details, read_sql_query fail on linestring tables with Keyerror: 14

mflaxman10 opened this issue · 3 comments

To replicate on community server:
pandas.DataFrame(con.get_table_details('ca_roads'))

Failed similarly on all line tables tested...

Full traceback:

KeyError Traceback (most recent call last)
in
----> 1 pd.DataFrame(con.get_table_details('ca_roads'))

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pymapd/connection.py in get_table_details(self, table_name)
348 """
349 details = self._client.get_table_details(self._session, table_name)
--> 350 return _extract_column_details(details.row_desc)
351
352 def create_table(self, table_name, data, preserve_index=False):

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pymapd/_parsers.py in _extract_column_details(row_desc)
93 x.col_type.nullable, x.col_type.precision,
94 x.col_type.scale, x.col_type.comp_param)
---> 95 for x in row_desc
96 ]
97

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pymapd/_parsers.py in (.0)
93 x.col_type.nullable, x.col_type.precision,
94 x.col_type.scale, x.col_type.comp_param)
---> 95 for x in row_desc
96 ]
97

KeyError: 14


Also affects "read_sql_query"


KeyError Traceback (most recent call last)
in
----> 1 gdf = omni2geopandas2('ca_roads', query="select * from ca_roads where countyFp = '061'")

in omni2geopandas2(omnitable, query)
5 else:
6 q = query
----> 7 df = pd.read_sql_query(q, con)
8 # to do: figure out geo_col, supporting older mapd_geo and odd-ball other cases
9 # like non-standard geometry column names

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pandas/io/sql.py in read_sql_query(sql, con, index_col, coerce_float, params, parse_dates, chunksize)
312 return pandas_sql.read_query(
313 sql, index_col=index_col, params=params, coerce_float=coerce_float,
--> 314 parse_dates=parse_dates, chunksize=chunksize)
315
316

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pandas/io/sql.py in read_query(self, sql, index_col, coerce_float, params, parse_dates, chunksize)
1475 parse_dates=parse_dates)
1476 else:
-> 1477 data = self._fetchall_as_list(cursor)
1478 cursor.close()
1479

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pandas/io/sql.py in _fetchall_as_list(self, cur)
1484
1485 def _fetchall_as_list(self, cur):
-> 1486 result = cur.fetchall()
1487 if not isinstance(result, list):
1488 result = list(result)

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pymapd/cursor.py in fetchall(self)
168 def fetchall(self):
169 # type: () -> Any
--> 170 return list(self)
171
172 def setinputsizes(self, sizes):

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pymapd/cursor.py in make_row_results_set(data)
202 columns = [_extract_col_vals(desc, col)
203 for desc, col in zip(data.row_set.row_desc,
--> 204 data.row_set.columns)]
205 for i in range(nrows):
206 yield tuple(columns[j][i] for j in range(ncols))

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pymapd/cursor.py in (.0)
201 ncols = len(data.row_set.row_desc)
202 columns = [_extract_col_vals(desc, col)
--> 203 for desc, col in zip(data.row_set.row_desc,
204 data.row_set.columns)]
205 for i in range(nrows):

~/miniconda3/envs/cudf/lib/python3.6/site-packages/pymapd/_parsers.py in _extract_col_vals(desc, val)
52 def _extract_col_vals(desc, val):
53 # type: (T.TColumnType, T.TColumn) -> Any
---> 54 typename = T.TDatumType._VALUES_TO_NAMES[desc.col_type.type]
55 nulls = val.nulls
56

KeyError: 14

Works for me, pymapd version 0.19.0

In [4]: pandas.DataFrame(con.get_table_details('ca_roads'))                     
Out[4]: 
           name        type  nullable  ...  comp_param  encoding  is_array
0       STATEFP         STR      True  ...          32      DICT     False
1      COUNTYFP         STR      True  ...          32      DICT     False
2          TLID      BIGINT      True  ...           0      NONE     False
3         TFIDL      BIGINT      True  ...           0      NONE     False
4         TFIDR      BIGINT      True  ...           0      NONE     False
5         MTFCC         STR      True  ...          32      DICT     False
6      FULLNAME         STR      True  ...          32      DICT     False
7          SMID         STR      True  ...          32      DICT     False
8      LFROMADD         STR      True  ...          32      DICT     False

Yes, I would not expect pymapd version 0.3.2 to be valid against any recent version of OmniSci