use of org.apache.hive.service.cli.RowSet in project cdap by caskdata.
the class Hive13ExploreService method doFetchNextResults.
@SuppressWarnings("unchecked")
@Override
protected List<QueryResult> doFetchNextResults(OperationHandle handle, FetchOrientation fetchOrientation, int size) throws Exception {
Class cliServiceClass = Class.forName("org.apache.hive.service.cli.CLIService");
Method fetchResultsMethod = cliServiceClass.getMethod("fetchResults", OperationHandle.class, FetchOrientation.class, Long.TYPE);
RowSet rowSet = (RowSet) fetchResultsMethod.invoke(getCliService(), handle, fetchOrientation, size);
ImmutableList.Builder<QueryResult> rowsBuilder = ImmutableList.builder();
for (Object[] row : rowSet) {
List<Object> cols = Lists.newArrayList(row);
rowsBuilder.add(new QueryResult(cols));
}
return rowsBuilder.build();
}
use of org.apache.hive.service.cli.RowSet in project hive by apache.
the class BeelineWithHS2ConnectionFileTestBase method createTable.
protected void createTable() throws HiveSQLException {
CLIServiceClient serviceClient = miniHS2.getServiceClient();
SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
serviceClient.executeStatement(sessHandle, "DROP TABLE IF EXISTS " + tableName, confOverlay);
serviceClient.executeStatement(sessHandle, "CREATE TABLE " + tableName + " (id INT)", confOverlay);
OperationHandle opHandle = serviceClient.executeStatement(sessHandle, "SHOW TABLES", confOverlay);
RowSet rowSet = serviceClient.fetchResults(opHandle);
assertFalse(rowSet.numRows() == 0);
}
use of org.apache.hive.service.cli.RowSet 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.RowSet in project hive by apache.
the class TestOperationLoggingAPIWithMr method testFetchResultsOfLogWithOrientation.
@Test
public void testFetchResultsOfLogWithOrientation() throws Exception {
// (FETCH_FIRST) execute a sql, and fetch its sql operation log as expected value
OperationHandle operationHandle = client.executeStatement(sessionHandle, sql, null);
RowSet rowSetLog = client.fetchResults(operationHandle, FetchOrientation.FETCH_FIRST, 1000, FetchType.LOG);
int expectedLogLength = rowSetLog.numRows();
// (FETCH_NEXT) execute the same sql again,
// and fetch the sql operation log with FETCH_NEXT orientation
OperationHandle operationHandleWithOrientation = client.executeStatement(sessionHandle, sql, null);
RowSet rowSetLogWithOrientation;
int logLength = 0;
int maxRows = calculateProperMaxRows(expectedLogLength);
do {
rowSetLogWithOrientation = client.fetchResults(operationHandleWithOrientation, FetchOrientation.FETCH_NEXT, maxRows, FetchType.LOG);
logLength += rowSetLogWithOrientation.numRows();
} while (rowSetLogWithOrientation.numRows() == maxRows);
Assert.assertEquals(expectedLogLength, logLength);
// (FETCH_FIRST) fetch again from the same operation handle with FETCH_FIRST orientation
rowSetLogWithOrientation = client.fetchResults(operationHandleWithOrientation, FetchOrientation.FETCH_FIRST, 1000, FetchType.LOG);
verifyFetchedLog(rowSetLogWithOrientation, expectedLogsVerbose);
}
use of org.apache.hive.service.cli.RowSet in project hive by apache.
the class TestOperationLoggingLayout 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;
}
Aggregations