Search in sources :

Example 16 with OperationHandle

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 {
        operation.run();
        addOpHandle(opHandle);
        return opHandle;
    } catch (HiveSQLException e) {
        operationManager.closeOperation(opHandle);
        throw e;
    } finally {
        release(true, true);
    }
}
Also used : GetTableTypesOperation(org.apache.hive.service.cli.operation.GetTableTypesOperation) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) OperationManager(org.apache.hive.service.cli.operation.OperationManager) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Example 17 with OperationHandle

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

the class HiveSessionImpl method getCatalogs.

@Override
public OperationHandle getCatalogs() throws HiveSQLException {
    acquire(true, true);
    OperationManager operationManager = getOperationManager();
    GetCatalogsOperation operation = operationManager.newGetCatalogsOperation(getSession());
    OperationHandle opHandle = operation.getHandle();
    try {
        operation.run();
        addOpHandle(opHandle);
        return opHandle;
    } catch (HiveSQLException e) {
        operationManager.closeOperation(opHandle);
        throw e;
    } finally {
        release(true, true);
    }
}
Also used : GetCatalogsOperation(org.apache.hive.service.cli.operation.GetCatalogsOperation) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) OperationManager(org.apache.hive.service.cli.operation.OperationManager) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Example 18 with OperationHandle

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

the class HiveSessionImpl method getCrossReference.

@Override
public OperationHandle getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws HiveSQLException {
    acquire(true, true);
    OperationManager operationManager = getOperationManager();
    GetCrossReferenceOperation operation = operationManager.newGetCrossReferenceOperation(getSession(), primaryCatalog, primarySchema, primaryTable, foreignCatalog, foreignSchema, foreignTable);
    OperationHandle opHandle = operation.getHandle();
    try {
        operation.run();
        addOpHandle(opHandle);
        return opHandle;
    } catch (HiveSQLException e) {
        operationManager.closeOperation(opHandle);
        throw e;
    } finally {
        release(true, true);
    }
}
Also used : GetCrossReferenceOperation(org.apache.hive.service.cli.operation.GetCrossReferenceOperation) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) OperationManager(org.apache.hive.service.cli.operation.OperationManager) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Example 19 with OperationHandle

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 {
        operation.run();
        addOpHandle(opHandle);
        return opHandle;
    } catch (HiveSQLException e) {
        operationManager.closeOperation(opHandle);
        throw e;
    } finally {
        release(true, true);
    }
}
Also used : HiveSQLException(org.apache.hive.service.cli.HiveSQLException) IMetaStoreClient(org.apache.hadoop.hive.metastore.IMetaStoreClient) OperationManager(org.apache.hive.service.cli.operation.OperationManager) OperationHandle(org.apache.hive.service.cli.OperationHandle) GetColumnsOperation(org.apache.hive.service.cli.operation.GetColumnsOperation)

Example 20 with OperationHandle

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

the class HiveSessionImpl method executeStatementInternal.

private OperationHandle executeStatementInternal(String statement, Map<String, String> confOverlay, boolean runAsync, long queryTimeout) throws HiveSQLException {
    acquire(true, true);
    ExecuteStatementOperation operation = null;
    OperationHandle opHandle = null;
    try {
        operation = getOperationManager().newExecuteStatementOperation(getSession(), statement, confOverlay, runAsync, queryTimeout);
        opHandle = operation.getHandle();
        operation.run();
        addOpHandle(opHandle);
        return opHandle;
    } catch (HiveSQLException e) {
        // opHandle directly when got HiveSQLException
        if (opHandle != null) {
            getOperationManager().closeOperation(opHandle);
        }
        throw e;
    } finally {
        if (operation == null || operation.getBackgroundHandle() == null) {
            // Not async, or wasn't submitted for some reason (failure, etc.)
            release(true, true);
        } else {
            // Release, but keep the lock (if present).
            releaseBeforeOpLock(true);
        }
    }
}
Also used : ExecuteStatementOperation(org.apache.hive.service.cli.operation.ExecuteStatementOperation) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Aggregations

OperationHandle (org.apache.hive.service.cli.OperationHandle)77 HiveSQLException (org.apache.hive.service.cli.HiveSQLException)54 SessionHandle (org.apache.hive.service.cli.SessionHandle)38 TException (org.apache.thrift.TException)27 Test (org.junit.Test)22 IOException (java.io.IOException)18 RowSet (org.apache.hive.service.cli.RowSet)16 UnknownHostException (java.net.UnknownHostException)15 LoginException (javax.security.auth.login.LoginException)15 ServiceException (org.apache.hive.service.ServiceException)15 ExploreException (co.cask.cdap.explore.service.ExploreException)12 OperationManager (org.apache.hive.service.cli.operation.OperationManager)12 QueryHandle (co.cask.cdap.proto.QueryHandle)11 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)11 OperationStatus (org.apache.hive.service.cli.OperationStatus)5 HashMap (java.util.HashMap)4 CLIServiceClient (org.apache.hive.service.cli.CLIServiceClient)4 OperationState (org.apache.hive.service.cli.OperationState)4 NamespaceNotFoundException (co.cask.cdap.common.NamespaceNotFoundException)2 HandleNotFoundException (co.cask.cdap.explore.service.HandleNotFoundException)2