Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when converting results to pandas in trino #948

Open
edublancas opened this issue Nov 22, 2023 · 0 comments
Open

error when converting results to pandas in trino #948

edublancas opened this issue Nov 22, 2023 · 0 comments

Comments

@edublancas
Copy link

reported by a slack user:

image

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[15], line 1
----> 1 sql_df.DataFrame()
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/ploomber_core/telemetry/telemetry.py:640, in Telemetry.log_call.<locals>._log_call.<locals>.wrapper(*args, **kwargs)
    638     injected_args = list(args)
    639     injected_args.insert(1, _payload)
--> 640     result = func(*injected_args, **kwargs)
    641 else:
    642     result = func(_payload, *args, **kwargs)
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sql/run/resultset.py:253, in ResultSet.DataFrame(self, payload)
    250 payload["connection_info"] = self._conn._get_database_information()
    251 import pandas as pd
--> 253 return _convert_to_data_frame(self, "df", pd.DataFrame)
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sql/run/resultset.py:521, in _convert_to_data_frame(result_set, converter_name, constructor, constructor_kwargs)
    518 if converter_name == "df":
    519     constructor_kwargs["columns"] = result_set.keys
--> 521 frame = constructor(
    522     (tuple(row) for row in result_set),
    523     **constructor_kwargs,
    524 )
    526 return frame
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/pandas/core/frame.py:684, in DataFrame.__init__(self, data, index, columns, dtype, copy)
    682 elif is_list_like(data):
    683     if not isinstance(data, (abc.Sequence, ExtensionArray)):
--> 684         data = list(data)
    685     if len(data) > 0:
    686         if is_dataclass(data[0]):
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sql/run/resultset.py:522, in <genexpr>(.0)
    518 if converter_name == "df":
    519     constructor_kwargs["columns"] = result_set.keys
    521 frame = constructor(
--> 522     (tuple(row) for row in result_set),
    523     **constructor_kwargs,
    524 )
    526 return frame
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sql/run/resultset.py:197, in ResultSet.__iter__(self)
    196 def __iter__(self):
--> 197     self.fetchall()
    199     for result in self._results:
    200         yield result
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sql/run/resultset.py:450, in ResultSet.fetchall(self)
    448 def fetchall(self):
    449     if not self._done_fetching():
--> 450         self._extend_results(self.sqlaproxy.fetchall())
    451         self.mark_fetching_as_done()
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/engine/result.py:1072, in Result.fetchall(self)
   1069 def fetchall(self):
   1070     """A synonym for the :meth:`_engine.Result.all` method."""
-> 1072     return self._allrows()
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/engine/result.py:401, in ResultInternal._allrows(self)
    397 post_creational_filter = self._post_creational_filter
    399 make_row = self._row_getter
--> 401 rows = self._fetchall_impl()
    402 if make_row:
    403     made_rows = [make_row(row) for row in rows]
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/engine/cursor.py:1819, in CursorResult._fetchall_impl(self)
   1818 def _fetchall_impl(self):
-> 1819     return self.cursor_strategy.fetchall(self, self.cursor)
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/engine/cursor.py:995, in CursorFetchStrategy.fetchall(self, result, dbapi_cursor)
    993     return rows
    994 except BaseException as e:
--> 995     self.handle_exception(result, dbapi_cursor, e)
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/engine/cursor.py:955, in CursorFetchStrategy.handle_exception(self, result, dbapi_cursor, err)
    954 def handle_exception(self, result, dbapi_cursor, err):
--> 955     result.connection._handle_dbapi_exception(
    956         err, None, None, dbapi_cursor, result.context
    957     )
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/engine/base.py:2138, in Connection._handle_dbapi_exception(self, e, statement, parameters, cursor, context)
   2134         util.raise_(
   2135             sqlalchemy_exception, with_traceback=exc_info[2], from_=e
   2136         )
   2137     else:
-> 2138         util.raise_(exc_info[1], with_traceback=exc_info[2])
   2140 finally:
   2141     del self._reentrant_error
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/util/compat.py:211, in raise_(***failed resolving arguments***)
    208     exception.__cause__ = replace_context
    210 try:
--> 211     raise exception
    212 finally:
    213     # credit to
    214     # https://cosmicpercolator.com/2016/01/13/exception-leaks-in-python-2-and-3/
    215     # as the __traceback__ object creates a cycle
    216     del exception, replace_context, from_, with_traceback
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/sqlalchemy/engine/cursor.py:991, in CursorFetchStrategy.fetchall(self, result, dbapi_cursor)
    989 def fetchall(self, result, dbapi_cursor):
    990     try:
--> 991         rows = dbapi_cursor.fetchall()
    992         result._soft_close()
    993         return rows
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/trino/dbapi.py:558, in Cursor.fetchall(self)
    557 def fetchall(self) -> List[List[Any]]:
--> 558     return list(self.genall())
​
File ~/.conda/envs/General_Purpose/lib/python3.11/site-packages/trino/client.py:502, in TrinoResult.__iter__(self)
    500 def __iter__(self):
    501     # Initial fetch from the first POST request
--> 502     for row in self._rows:
    503         self._rownumber += 1
    504         yield row
​
TypeError: 'NoneType' object is not iterable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant