Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

hive jdbc Statement.getUpdateCount() always returning -1

avatar
New Member

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;
  }

.