Hive JDBC 连接返回"query did not generate a resultset"



我已经从git构建了hive-jdbc,并试图执行一个基本的jdbc查询来获取结果集。由于某些原因,查询抛出了以下异常。

16/07/01 22:08:12 INFO Utils: Supplied authorities: localhost:10000 
16/07/01 22:08:12 INFO Utils: Resolved authority: localhost:10000 
16/07/01 22:08:12 DEBUG TSaslTransport: opening transport org.apache.thrift.transport.TSaslClientTransport@55360888 
16/07/01 22:08:12 DEBUG TSaslClientTransport: Sending mechanism name PLAIN and initial response of length 16 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Writing message with status START and payload length 5 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Writing message with status COMPLETE and payload length 16 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Start message handled 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Main negotiation loop complete 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: SASL Client receiving last message 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: Received message with status COMPLETE and payload length 0 
16/07/01 22:08:12 DEBUG TSaslTransport: writing data length: 71 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: reading data length: 109 
16/07/01 22:08:12 DEBUG TSaslTransport: writing data length: 183 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: reading data length: 109 
16/07/01 22:08:12 DEBUG TSaslTransport: writing data length: 100 
16/07/01 22:08:12 DEBUG TSaslTransport: CLIENT: reading data length: 53 
Exception in thread "main" java.sql.SQLException: The query did not generate a result set!  
   at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:459)   
   at com.kris.mond.sample.HiveQuery.main(HiveQuery.java:20)
下面是我使用的代码片段,
     try { 
         Class.forName("org.apache.hive.jdbc.HiveDriver");
        } catch (ClassNotFoundException e) { 
            System.err.println("Could not load the driver");
            System.exit(1);
        } 
     Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/default", "hduser", "*******");
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery("select account_id,account_parent,account_description from account");

根据另一篇文章的建议,我正在使用executeQuery的DML,但仍然无法获取结果集。

如果你能帮助我,我会很感激的。

我已经设法在HiveStatement.java中的以下补丁后获得结果集

public boolean execute(String sql) throws SQLException {
    runAsyncOnServer(sql);
    TGetOperationStatusResp status = waitForOperationToComplete();
    **// The query should be completed by now
 -->   /*if (!status.isHasResultSet()) {
 -->     return false;
 -->   }*/**
    resultSet =  new HiveQueryResultSet.Builder(this).setClient(client).setSessionHandle(sessHandle)
        .setStmtHandle(stmtHandle).setMaxRows(maxRows).setFetchSize(fetchSize)
        .setScrollable(isScrollableResultset)
        .build();
    return true;
  }

由于某些原因status.isHasResultSet()返回false,即使结果集可用

最新更新