use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class TestQueryDisplay method testWebUI.
/**
* Test if webui captures information on current/historic SQL operations.
*/
@Test
public void testWebUI() throws Exception {
HiveSession session = sessionManager.createSession(new SessionHandle(TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8), TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V8, "testuser", "", "", new HashMap<String, String>(), false, "");
SessionState.start(conf);
OperationHandle opHandle1 = session.executeStatement("show databases", null);
SessionState.start(conf);
OperationHandle opHandle2 = session.executeStatement("show tables", null);
verifyDDLHtml("show databases", opHandle1.getHandleIdentifier().toString());
verifyDDLHtml("show tables", opHandle2.getHandleIdentifier().toString());
session.closeOperation(opHandle1);
session.closeOperation(opHandle2);
verifyDDLHtml("show databases", opHandle1.getHandleIdentifier().toString());
verifyDDLHtml("show tables", opHandle2.getHandleIdentifier().toString());
session.close();
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class TestHiveServer2 method testGetVariableValue.
/**
* Open a new session and execute a set command
* @throws Exception
*/
@Test
public void testGetVariableValue() throws Exception {
CLIServiceClient serviceClient = miniHS2.getServiceClient();
SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
OperationHandle opHandle = serviceClient.executeStatement(sessHandle, "set system:os.name", confOverlay);
RowSet rowSet = serviceClient.fetchResults(opHandle);
assertEquals(1, rowSet.numRows());
serviceClient.closeSession(sessHandle);
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class OperationLoggingAPITestBase method testFetchResultsOfLogWithExecutionMode.
@Test
public void testFetchResultsOfLogWithExecutionMode() throws Exception {
try {
String queryString = "set hive.server2.logging.operation.level=execution";
client.executeStatement(sessionHandle, queryString, null);
// verify whether the sql operation log is generated and fetch correctly.
OperationHandle operationHandle = client.executeStatement(sessionHandle, sqlCntStar, null);
RowSet rowSetLog = client.fetchResults(operationHandle, FetchOrientation.FETCH_FIRST, 1000, FetchType.LOG);
verifyFetchedLog(rowSetLog, expectedLogsExecution);
verifyMissingContentsInFetchedLog(rowSetLog, expectedLogsPerformance);
verifyMissingContentsInFetchedLog(rowSetLog, expectedLogsVerbose);
} finally {
// Restore everything to default setup to avoid discrepancy between junit test runs
String queryString2 = "set hive.server2.logging.operation.level=verbose";
client.executeStatement(sessionHandle, queryString2, null);
}
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class OperationLoggingAPITestBase method setupSession.
private SessionHandle setupSession() throws Exception {
// Open a session
SessionHandle sessionHandle = client.openSession(null, null, null);
// Change lock manager to embedded mode
String queryString = "SET hive.lock.manager=" + "org.apache.hadoop.hive.ql.lockmgr.EmbeddedLockManager";
client.executeStatement(sessionHandle, queryString, null);
// Drop the table if it exists
queryString = "DROP TABLE IF EXISTS " + tableName;
client.executeStatement(sessionHandle, queryString, null);
// Create a test table
queryString = "create table " + tableName + " (key int, value string)";
client.executeStatement(sessionHandle, queryString, null);
// Load data
queryString = "load data local inpath '" + dataFile + "' into table " + tableName;
client.executeStatement(sessionHandle, queryString, null);
// Precondition check: verify whether the table is created and data is fetched correctly.
OperationHandle operationHandle = client.executeStatement(sessionHandle, sql, null);
RowSet rowSetResult = client.fetchResults(operationHandle);
Assert.assertEquals(500, rowSetResult.numRows());
Assert.assertEquals(238, rowSetResult.iterator().next()[0]);
Assert.assertEquals("val_238", rowSetResult.iterator().next()[1]);
return sessionHandle;
}
use of org.apache.hive.service.cli.OperationHandle in project hive by apache.
the class OperationLoggingAPITestBase method testFetchResultsOfLogWithPerformanceMode.
@Test
public void testFetchResultsOfLogWithPerformanceMode() throws Exception {
try {
String queryString = "set hive.server2.logging.operation.level=performance";
client.executeStatement(sessionHandle, queryString, null);
// verify whether the sql operation log is generated and fetch correctly.
OperationHandle operationHandle = client.executeStatement(sessionHandle, sqlCntStar, null);
RowSet rowSetLog = client.fetchResults(operationHandle, FetchOrientation.FETCH_FIRST, 1000, FetchType.LOG);
// rowSetLog should contain execution as well as performance logs
verifyFetchedLog(rowSetLog, expectedLogsExecution);
verifyFetchedLog(rowSetLog, expectedLogsPerformance);
verifyMissingContentsInFetchedLog(rowSetLog, expectedLogsVerbose);
} finally {
// Restore everything to default setup to avoid discrepancy between junit test runs
String queryString2 = "set hive.server2.logging.operation.level=verbose";
client.executeStatement(sessionHandle, queryString2, null);
}
}
Aggregations