Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

hive jdbc Statement.getUpdateCount() always returning -1

avatar
New Contributor

hive jdbc Statement.getUpdateCount() always returning -1, instead it should return number of rows inserted/updated/deleted.

Here is the sample code.

---------------------------------

Class.forName("org.apache.hive.jdbc.HiveDriver"); String url = "jdbc:hive2://XXXX:10000/default"; Connection con = DriverManager.getConnection(url, "XXX", "XXX");

Statement stmt = con.createStatement(); //HiveStatement stmt = (HiveStatement)con.createStatement();

String sql = "INSERT INTO TAB_CNT_2 select * from TAB_CNT_1"; //String sql = "LOAD DATA INPATH '/user/XXXXXX.txt' INTO TABLE TAB_CNT_2" stmt.execute(sql); System.out.println("update row count="+stmt.getUpdateCount()); stmt.close(); con.close();

----------------------------------

Looks like there are hive specific statement classes (HiveStatement, HivePreparedStatement) not sure how to instanciate these classes and also not sure if they return correct updateCount .

Appreciate any help.
1 ACCEPTED SOLUTION

avatar
Super Collaborator

This is not supported yet

View solution in original post

2 REPLIES 2

avatar
Super Collaborator

This is not supported yet

avatar
Master Mentor

@san ch

It is hardcoded to return "-1" and work as designed so far.

https://github.com/apache/hive/blob/master/jdbc/src/java/org/apache/hive/jdbc/HiveStatement.java#L68...

  public int getUpdateCount() throws SQLException {
    checkConnection("getUpdateCount");
    /**
     * Poll on the operation status, till the operation is complete. We want to ensure that since a
     * client might end up using executeAsync and then call this to check if the query run is
     * finished.
     */
    waitForOperationToComplete();
    return -1;
  }

.