Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetching data with snowflake connector throws EmptyPyArrowIterator error

I use python snowflake connector in my python script (plotly dash app) and today the app stopped working without me changing the code. I tried a couple of things to find out what might be the issue and I even tried to run the example code from Snowflake documentation and I got the same error:

code:

cur = conn.cursor()
try:
    cur.execute("SELECT col1, col2 FROM test_table ORDER BY col1")
    for (col1, col2) in cur:
        print('{0}, {1}'.format(col1, col2))
finally:
    cur.close()

error:

Traceback (most recent call last):
  File "db_connection.py", line 48, in <module>
    cur.execute("SELECT col1, col2 FROM test_table ORDER BY col1")
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/cursor.py", line 580, in execute
    self._init_result_and_meta(data, _use_ijson)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/snowflake/connector/cursor.py", line 630, in _init_result_and_meta
    self._result = ArrowResult(data, self, use_dict_result=self._use_dict_result)
  File "arrow_result.pyx", line 42, in snowflake.connector.arrow_result.ArrowResult.__init__
  File "arrow_result.pyx", line 156, in snowflake.connector.arrow_result.ArrowResult._reset
NameError: name 'EmptyPyArrowIterator' is not defined

The connection is established, I am capable of creating a table in my database but I cannot seem to query and iterate the data.

I am on macOS Catalina 10.15.1, snowflake-connector-python==2.1.0, Python 3.7.0.

like image 201
verope Avatar asked Dec 12 '19 14:12

verope


People also ask

How do I know if my Snowflake connector is installed?

To verify your driver version, connect to Snowflake through a client application that uses the driver and check the version. If the application supports executing SQL queries, you can call the CURRENT_CLIENT function. ODBC Driver: ODBC Data Source Administration Tool (Windows)

How do you extract data from a Snowflake?

Using the Query ID to Retrieve the Results of a Query Get the query ID of the query. See Retrieving the Snowflake Query ID. Call the get_results_from_sfqid() method in the Cursor object to retrieve the results. Use the Cursor object to fetch the values in the results, as explained in Using cursor to Fetch Values.


1 Answers

You have to install pyarrow module via

pip3 install pyarrow

Installation of the snowflake connector does not automatically install it.

like image 106
Jeff Horn Avatar answered Oct 07 '22 23:10

Jeff Horn