Julien Letrouit created HIVE-5089:
-------------------------------------
Summary: Non query PreparedStatements are always failing on remote
HiveServer2
Key: HIVE-5089
URL: https://issues.apache.org/jira/browse/HIVE-5089
Project: Hive
Issue Type: Bug
Components: JDBC
Affects Versions: 0.11.0
Reporter: Julien Letrouit
This is reproducing the issue systematically:
import org.apache.hive.jdbc.HiveDriver;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class Main {
public static void main(String[] args) throws Exception {
DriverManager.registerDriver(new HiveDriver());
Connection conn = DriverManager.getConnection("jdbc:hive2://someserver");
PreparedStatement smt = conn.prepareStatement("SET hivevar:test=1");
smt.execute(); // Exception here
conn.close();
}
}
It is producing the following stacktrace:
Exception in thread "main" java.sql.SQLException: Could not create ResultSet:
null
at
org.apache.hive.jdbc.HiveQueryResultSet.retrieveSchema(HiveQueryResultSet.java:183)
at org.apache.hive.jdbc.HiveQueryResultSet.<init>(HiveQueryResultSet.java:134)
at
org.apache.hive.jdbc.HiveQueryResultSet$Builder.build(HiveQueryResultSet.java:122)
at
org.apache.hive.jdbc.HivePreparedStatement.executeImmediate(HivePreparedStatement.java:194)
at
org.apache.hive.jdbc.HivePreparedStatement.execute(HivePreparedStatement.java:137)
at Main.main(Main.java:12)
Caused by: org.apache.thrift.transport.TTransportException
at
org.apache.thrift.transport.TIOStreamTransport.read(TIOStreamTransport.java:132)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
at
org.apache.thrift.transport.TSaslTransport.readLength(TSaslTransport.java:346)
at
org.apache.thrift.transport.TSaslTransport.readFrame(TSaslTransport.java:423)
at org.apache.thrift.transport.TSaslTransport.read(TSaslTransport.java:405)
at
org.apache.thrift.transport.TSaslClientTransport.read(TSaslClientTransport.java:37)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
at
org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
at
org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
at
org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
at
org.apache.hive.service.cli.thrift.TCLIService$Client.recv_GetResultSetMetadata(TCLIService.java:466)
at
org.apache.hive.service.cli.thrift.TCLIService$Client.GetResultSetMetadata(TCLIService.java:453)
at
org.apache.hive.jdbc.HiveQueryResultSet.retrieveSchema(HiveQueryResultSet.java:154)
... 5 more
I tried to fix it, unfortunately, the standalone server used in unit tests do
not reproduce the issue. The following test added to TestJdbcDriver2 is passing:
public void testNonQueryPrepareStatement() throws Exception {
try {
PreparedStatement ps = con.prepareStatement("SET hivevar:test=1");
boolean hasResultSet = ps.execute();
assertTrue(hasResultSet);
ps.close();
} catch (Exception e) {
e.printStackTrace();
fail(e.toString());
}
}
Any guidance on how to reproduce it in tests would be appreciated.
Impact: the data analysis tools we are using are performing PreparedStatements.
The use of custom UDF is forcing us to add 'ADD JAR ...' and 'CREATE TEMPORARY
FUNCTION ...' statement to our query. Those statements are failing when
executed as PreparedStatements.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira