Search in sources :

Example 81 with OperationHandle

use of org.apache.hive.service.cli.OperationHandle in project hive by apache.

the class HiveSessionImpl method uploadData.

@Override
public OperationHandle uploadData(ByteBuffer values, String tableName, String path) throws HiveSQLException {
    acquire(true, true);
    OperationManager operationManager = getOperationManager();
    Operation operation = operationManager.newUploadDataOperation(getSession(), values, tableName, path);
    OperationHandle opHandle = operation.getHandle();
    try {
        operation.run();
        opHandleSet.add(opHandle);
        return opHandle;
    } catch (HiveSQLException e) {
        operationManager.closeOperation(opHandle);
        throw e;
    } finally {
        release(true, true);
    }
}
Also used : HiveSQLException(org.apache.hive.service.cli.HiveSQLException) Operation(org.apache.hive.service.cli.operation.Operation) ExecuteStatementOperation(org.apache.hive.service.cli.operation.ExecuteStatementOperation) GetSchemasOperation(org.apache.hive.service.cli.operation.GetSchemasOperation) GetCrossReferenceOperation(org.apache.hive.service.cli.operation.GetCrossReferenceOperation) GetColumnsOperation(org.apache.hive.service.cli.operation.GetColumnsOperation) MetadataOperation(org.apache.hive.service.cli.operation.MetadataOperation) GetPrimaryKeysOperation(org.apache.hive.service.cli.operation.GetPrimaryKeysOperation) GetFunctionsOperation(org.apache.hive.service.cli.operation.GetFunctionsOperation) GetTypeInfoOperation(org.apache.hive.service.cli.operation.GetTypeInfoOperation) GetCatalogsOperation(org.apache.hive.service.cli.operation.GetCatalogsOperation) GetTableTypesOperation(org.apache.hive.service.cli.operation.GetTableTypesOperation) OperationManager(org.apache.hive.service.cli.operation.OperationManager) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Example 82 with OperationHandle

use of org.apache.hive.service.cli.OperationHandle in project hive by apache.

the class HiveSessionImpl method getTypeInfo.

@Override
public OperationHandle getTypeInfo() throws HiveSQLException {
    acquire(true, true);
    OperationManager operationManager = getOperationManager();
    GetTypeInfoOperation operation = operationManager.newGetTypeInfoOperation(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);
    }
}
Also used : GetTypeInfoOperation(org.apache.hive.service.cli.operation.GetTypeInfoOperation) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) OperationManager(org.apache.hive.service.cli.operation.OperationManager) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Example 83 with OperationHandle

use of org.apache.hive.service.cli.OperationHandle in project hive by apache.

the class ThriftCLIServiceClient method getCrossReference.

@Override
public OperationHandle getCrossReference(SessionHandle sessionHandle, String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws HiveSQLException {
    try {
        TGetCrossReferenceReq req = new TGetCrossReferenceReq(sessionHandle.toTSessionHandle());
        req.setParentCatalogName(primaryCatalog);
        req.setParentSchemaName(primarySchema);
        req.setParentTableName(primaryTable);
        req.setForeignCatalogName(foreignCatalog);
        req.setForeignSchemaName(foreignSchema);
        req.setForeignTableName(foreignTable);
        TGetCrossReferenceResp resp = cliService.GetCrossReference(req);
        checkStatus(resp.getStatus());
        TProtocolVersion protocol = sessionHandle.getProtocolVersion();
        return new OperationHandle(resp.getOperationHandle(), protocol);
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) TGetCrossReferenceReq(org.apache.hive.service.rpc.thrift.TGetCrossReferenceReq) TGetCrossReferenceResp(org.apache.hive.service.rpc.thrift.TGetCrossReferenceResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TOperationHandle(org.apache.hive.service.rpc.thrift.TOperationHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 84 with OperationHandle

use of org.apache.hive.service.cli.OperationHandle in project hive by apache.

the class ThriftCLIServiceClient method getSchemas.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getSchemas(org.apache.hive.service.cli.SessionHandle, java.lang.String, java.lang.String)
   */
@Override
public OperationHandle getSchemas(SessionHandle sessionHandle, String catalogName, String schemaName) throws HiveSQLException {
    try {
        TGetSchemasReq req = new TGetSchemasReq(sessionHandle.toTSessionHandle());
        req.setCatalogName(catalogName);
        req.setSchemaName(schemaName);
        TGetSchemasResp resp = cliService.GetSchemas(req);
        checkStatus(resp.getStatus());
        TProtocolVersion protocol = sessionHandle.getProtocolVersion();
        return new OperationHandle(resp.getOperationHandle(), protocol);
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TGetSchemasReq(org.apache.hive.service.rpc.thrift.TGetSchemasReq) TGetSchemasResp(org.apache.hive.service.rpc.thrift.TGetSchemasResp) TOperationHandle(org.apache.hive.service.rpc.thrift.TOperationHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 85 with OperationHandle

use of org.apache.hive.service.cli.OperationHandle in project hive by apache.

the class QueryInfoCache method removeLiveQueryInfo.

/**
 * Remove the live operation's query info from the {@liveQueryInfos},
 * and push the query info to the historic query cache if enabled.
 * @param operation the to remove operation
 */
public void removeLiveQueryInfo(Operation operation) {
    if (operation instanceof SQLOperation) {
        OperationHandle operationHandle = operation.getHandle();
        synchronized (webuiLock) {
            String opKey = operationHandle.getHandleIdentifier().toString();
            // remove from list of live operations
            QueryInfo display = liveQueryInfos.remove(opKey);
            if (display == null) {
                LOG.debug("Unexpected display object value of null for operation {}", opKey);
            } else if (historicalQueryInfos != null) {
                // add to list of saved historic operations
                historicalQueryInfos.put(opKey, display);
            }
        }
    }
}
Also used : QueryInfo(org.apache.hadoop.hive.ql.QueryInfo) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Aggregations

OperationHandle (org.apache.hive.service.cli.OperationHandle)104 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)63 SessionHandle (org.apache.hive.service.cli.SessionHandle)47 Test (org.junit.Test)35 TException (org.apache.thrift.TException)31 RowSet (org.apache.hive.service.cli.RowSet)21 IOException (java.io.IOException)20 UnknownHostException (java.net.UnknownHostException)17 LoginException (javax.security.auth.login.LoginException)17 ServiceException (org.apache.hive.service.ServiceException)17 OperationManager (org.apache.hive.service.cli.operation.OperationManager)14 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)13 ExploreException (co.cask.cdap.explore.service.ExploreException)12 TOperationHandle (org.apache.hive.service.rpc.thrift.TOperationHandle)12 QueryHandle (co.cask.cdap.proto.QueryHandle)11 OperationStatus (org.apache.hive.service.cli.OperationStatus)8 HashMap (java.util.HashMap)7 CLIServiceClient (org.apache.hive.service.cli.CLIServiceClient)6 ArrayList (java.util.ArrayList)5 OperationState (org.apache.hive.service.cli.OperationState)5