Created 03-28-2017 03:27 PM
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.Created 03-28-2017 04:10 PM
This is not supported yet
Created 03-28-2017 04:10 PM
This is not supported yet
Created 03-28-2017 04:33 PM
It is hardcoded to return "-1" and work as designed so far.
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; }
.