use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class HiveSessionImpl method getColumns.
@Override
public OperationHandle getColumns(String catalogName, String schemaName, String tableName, String columnName) throws HiveSQLException {
acquire(true, true);
String addedJars = Utilities.getResourceFiles(sessionConf, SessionState.ResourceType.JAR);
if (StringUtils.isNotBlank(addedJars)) {
IMetaStoreClient metastoreClient = getSession().getMetaStoreClient();
metastoreClient.setHiveAddedJars(addedJars);
}
OperationManager operationManager = getOperationManager();
GetColumnsOperation operation = operationManager.newGetColumnsOperation(getSession(), catalogName, schemaName, tableName, columnName);
OperationHandle opHandle = operation.getHandle();
try {
addOpHandle(opHandle);
operation.run();
return opHandle;
} catch (HiveSQLException e) {
removeOpHandle(opHandle);
operationManager.closeOperation(opHandle);
throw e;
} finally {
release(true, true);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class HiveSessionImpl method getTableTypes.
@Override
public OperationHandle getTableTypes() throws HiveSQLException {
acquire(true, true);
OperationManager operationManager = getOperationManager();
GetTableTypesOperation operation = operationManager.newGetTableTypesOperation(getSession());
OperationHandle opHandle = operation.getHandle();
try {
addOpHandle(opHandle);
operation.run();
return opHandle;
} catch (HiveSQLException e) {
removeOpHandle(opHandle);
operationManager.closeOperation(opHandle);
throw e;
} finally {
release(true, true);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class HiveSessionImpl method getFunctions.
@Override
public OperationHandle getFunctions(String catalogName, String schemaName, String functionName) throws HiveSQLException {
acquire(true, true);
OperationManager operationManager = getOperationManager();
GetFunctionsOperation operation = operationManager.newGetFunctionsOperation(getSession(), catalogName, schemaName, functionName);
OperationHandle opHandle = operation.getHandle();
try {
addOpHandle(opHandle);
operation.run();
return opHandle;
} catch (HiveSQLException e) {
removeOpHandle(opHandle);
operationManager.closeOperation(opHandle);
throw e;
} finally {
release(true, true);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class TestQueryShutdownHooks method testAsync.
@Test
public void testAsync() throws Exception {
int shutdownHooksBeforeQueries = ShutdownHookManagerInspector.getShutdownHookCount();
String[] someQueries = { "select reflect(\"java.lang.Thread\", \"sleep\", bigint(1000))", "select reflect(\"java.lang.Thread\", \"sleep\", bigint(1000))", "select reflect(\"java.lang.Thread\", \"sleep\", bigint(1000))", "select reflect(\"java.lang.Thread\", \"sleep\", bigint(1000))" };
List<OperationHandle> operationHandles = new ArrayList<>();
for (String queryStr : someQueries) {
OperationHandle opHandle = client.executeStatementAsync(sessionHandle, queryStr, confOverlay);
assertNotNull(opHandle);
operationHandles.add(opHandle);
}
boolean allComplete = false;
final long step = 200;
final long timeout = System.currentTimeMillis() + ASYNC_QUERY_TIMEOUT_MS;
while (!allComplete) {
allComplete = true;
for (OperationHandle opHandle : operationHandles) {
OperationStatus operationStatus = client.getOperationStatus(opHandle, false);
if (operationStatus.getState() != OperationState.FINISHED) {
if (System.currentTimeMillis() > timeout) {
fail("Queries did not complete timely");
}
allComplete = false;
Thread.sleep(step);
break;
}
}
}
ShutdownHookManagerInspector.assertShutdownHookCount(shutdownHooksBeforeQueries);
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class TestSessionGlobalInitFile method verifyInitProperty.
private void verifyInitProperty(String key, String value, SessionHandle sessionHandle) throws Exception {
OperationHandle operationHandle = client.executeStatement(sessionHandle, "set " + key, null);
RowSet rowSet = client.fetchResults(operationHandle);
Assert.assertEquals(1, rowSet.numRows());
// we know rowSet has only one element
Assert.assertEquals(key + "=" + value, rowSet.iterator().next()[0]);
client.closeOperation(operationHandle);
}
Aggregations