Snowflake JDBC driver internal error: Fail to retrieve row count for first arrow chunk: null -- only occurs on SELECT statements

Viewed 8410

I have successfully established the JDBC connection and can successfully execute statements like "use warehouse ...". When I try to run any SELECT statement I get the following error:

net.snowflake.client.jdbc.SnowflakeSQLLoggedException: JDBC driver internal error: Fail to retrieve row count for first arrow chunk: null.

I am able to see that my request was successful, and returned the expected data in the snowflake UI.

The error occurs on this line: rs = statement.executeQuery("select TOP 1 EVENT_ID from snowflake.account_usage.login_history");

The statement was able to execute queries prior to this line and the result set was as expected. Any insight would be appreciated!

6 Answers

This could happen due to several reasons:

  1. What JDK version are you using? JDK16 has introduced strong encapsulation of JDK internals (see JEP 396) If you're using JDK16 try setting at JVM level on startup:
-Djdk.module.illegalAccess=permit 

This is a workaround until we get a fix for the following Apache Arrow issue ARROW-12747

  1. If you use an application that uses JDBC to connect to Snowflake, then the application might not interpret correctly the results. Try switching back to JSON rather than ARROW format and see if that fixes it. This can be done at session level by running:
ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON'

Using DBeaver to connect snowflake and had the same issue. It is resolved by setting the session parameter in each editor window as following: ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON';

This solution can be automated by configuring boot-strap queries in connection settings->Initialization. With every new-editor window this session parameter will preset during initialization.

I hit the same problem, and was able to get it working by downgrading to Java 11 for version

[net.snowflake/snowflake-jdbc "3.13.8"]

The official solution from snowflake is to configure an extra property in your datasource configurations: https://community.snowflake.com/s/article/SAP-BW-Java-lang-NoClassDefFoundError-for-Apache-arrow

Customer can use this property (jdbc_query_result_format=json) in datasouce property of Application server or session property in application like

Statement = connection.createStatement();
Statement.executeQuery("ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON'");

which will use result format as JSON instead of Arrow and which will avoid the above error.

Before executing actual query you need to set this:

statement.executeQuery("ALTER SESSION SET JDBC_QUERY_RESULT_FORMAT='JSON'");

You can add the following 2 settings in the following file (macOS) /Applications/DBeaver.app/Contents/Eclipse/dbeaver.ini

-Djdk.module.illegalAccess=permit --add-opens=java.base/java.nio=ALL-UNNAMED

Information from: https://support.dbvis.com/support/solutions/articles/1000309803-snowflake-fail-to-retrieve-row-count-for-first-arrow-chunk-


Another alternative that worked for me on my MAC M1, is to use JDK11

brew install openjdk@11

Edit: /Applications/DBeaver.app/Contents/Eclipse/dbeaver.ini this line: ../Eclipse/jre/Contents/Home/bin/java change to /opt/homebrew/opt/openjdk@11/bin/java

Restart dbeaver

Related