use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.
the class TestHiveStatement method testSetFetchSizeZero.
/**
* Gives the JDBC driver a hint as to the number of rows that should be
* fetched from the database when more rows are needed for ResultSet objects
* generated by this Statement. If the value specified is zero, then the hint
* is ignored. Test for a value of zero (hint is ignored).
*/
@Test
public void testSetFetchSizeZero() throws SQLException {
final HiveConnection connection = mock(HiveConnection.class);
final Iface iface = mock(Iface.class);
final TSessionHandle handle = mock(TSessionHandle.class);
// so it falls-back to the configuration default value
try (HiveStatement stmt = new HiveStatement(connection, iface, handle)) {
stmt.setFetchSize(0);
assertEquals(HiveConf.ConfVars.HIVE_SERVER2_THRIFT_RESULTSET_DEFAULT_FETCH_SIZE.defaultIntVal, stmt.getFetchSize());
}
}
use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.
the class TestHiveStatement method testSetFetchSize.
/**
* Gives the JDBC driver a hint as to the number of rows that should be
* fetched from the database when more rows are needed for ResultSet objects
* generated by this Statement. If the value specified is zero, then the hint
* is ignored. Test a value greater than zero is accepted.
*/
@Test
public void testSetFetchSize() throws SQLException {
final HiveConnection connection = mock(HiveConnection.class);
final Iface iface = mock(Iface.class);
final TSessionHandle handle = mock(TSessionHandle.class);
try (HiveStatement stmt = new HiveStatement(connection, iface, handle)) {
stmt.setFetchSize(123);
assertEquals(123, stmt.getFetchSize());
}
}
use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.
the class SessionHandle method toTSessionHandle.
public TSessionHandle toTSessionHandle() {
TSessionHandle tSessionHandle = new TSessionHandle();
tSessionHandle.setSessionId(getHandleIdentifier().toTHandleIdentifier());
return tSessionHandle;
}
use of org.apache.hive.service.rpc.thrift.TSessionHandle in project hive by apache.
the class TestThriftCliServiceWithInfoMessage method testExecuteReturnWithInfoMessage.
@Test
public void testExecuteReturnWithInfoMessage() throws Exception {
TTransport transport = HiveAuthUtils.getSocketTransport(host, cliPort, 0);
try {
transport.open();
TCLIService.Iface client = new TCLIService.Client(new TBinaryProtocol(transport));
TOpenSessionReq openReq = new TOpenSessionReq();
openReq.setClient_protocol(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V11);
TOpenSessionResp sessionResp = client.OpenSession(openReq);
Map<String, String> serverHiveConf = sessionResp.getConfiguration();
assertNotNull(serverHiveConf);
assertTrue(Boolean.parseBoolean(serverHiveConf.get(ConfVars.HIVE_DEFAULT_NULLS_LAST.varname)));
TSessionHandle sessHandle = sessionResp.getSessionHandle();
TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, "select 1");
execReq.setRunAsync(true);
TExecuteStatementResp execResp = client.ExecuteStatement(execReq);
TStatus status = execResp.getStatus();
assertTrue(status.getStatusCode() == TStatusCode.SUCCESS_WITH_INFO_STATUS);
assertNotNull(status.getInfoMessages());
assertTrue(status.getInfoMessages().size() > 0);
Pattern pattern = Pattern.compile("http://.*:(\\d+)/query_page\\.html\\?operationId=(.+)$");
Matcher matcher = pattern.matcher(status.getInfoMessages().get(0));
assertTrue(matcher.find());
assertEquals(webuiPort + "", matcher.group(1));
OperationHandle operationHandle = new OperationHandle(execResp.getOperationHandle());
assertEquals(operationHandle.getHandleIdentifier().toString(), matcher.group(2));
// Cancel the operation
TCancelOperationReq cancelReq = new TCancelOperationReq();
cancelReq.setOperationHandle(execResp.getOperationHandle());
client.CancelOperation(cancelReq);
// Disable showing the link
Map<String, String> overlayConf = new HashMap<>();
overlayConf.put(ConfVars.HIVE_SERVER2_SHOW_OPERATION_DRILLDOWN_LINK.varname, "false");
execReq = new TExecuteStatementReq(sessHandle, "select 1");
execReq.setRunAsync(true);
execReq.setConfOverlay(overlayConf);
execResp = client.ExecuteStatement(execReq);
status = execResp.getStatus();
assertTrue(status.getStatusCode() == TStatusCode.SUCCESS_STATUS);
assertTrue(status.getInfoMessages() == null);
} finally {
transport.close();
}
}
Aggregations