Search in sources :

Example 36 with HiveSQLException

use of org.apache.hive.service.cli.HiveSQLException 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 {
        addOpHandle(opHandle);
        operation.run();
        return opHandle;
    } catch (HiveSQLException e) {
        removeOpHandle(opHandle);
        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 37 with HiveSQLException

use of org.apache.hive.service.cli.HiveSQLException 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 {
        addOpHandle(opHandle);
        operation.run();
        return opHandle;
    } catch (HiveSQLException e) {
        removeOpHandle(opHandle);
        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 38 with HiveSQLException

use of org.apache.hive.service.cli.HiveSQLException 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);
    }
}
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 39 with HiveSQLException

use of org.apache.hive.service.cli.HiveSQLException 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();
        addOpHandle(opHandle);
        operation.run();
        return opHandle;
    } catch (HiveSQLException e) {
        // opHandle directly when got HiveSQLException
        if (opHandle != null) {
            removeOpHandle(opHandle);
            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)

Example 40 with HiveSQLException

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

the class HiveSessionImplwithUGI method close.

/**
 * Close the file systems for the session and remove it from the FileSystem cache.
 * Cancel the session's delegation token and close the metastore connection
 */
@Override
public void close() throws HiveSQLException {
    try {
        acquire(true, false);
        cancelDelegationToken();
    } finally {
        release(true, false);
        try {
            super.close();
        } finally {
            try {
                FileSystem.closeAllForUGI(sessionUgi);
            } catch (IOException ioe) {
                throw new HiveSQLException("Could not clean up file-system handles for UGI: " + sessionUgi, ioe);
            }
        }
    }
}
Also used : HiveSQLException(org.apache.hive.service.cli.HiveSQLException) IOException(java.io.IOException)

Aggregations

HiveSQLException (org.apache.hive.service.cli.HiveSQLException)88 OperationHandle (org.apache.hive.service.cli.OperationHandle)39 TException (org.apache.thrift.TException)26 SessionHandle (org.apache.hive.service.cli.SessionHandle)20 ExploreException (co.cask.cdap.explore.service.ExploreException)14 IOException (java.io.IOException)12 QueryHandle (co.cask.cdap.proto.QueryHandle)11 TProtocolVersion (org.apache.hive.service.rpc.thrift.TProtocolVersion)11 OperationManager (org.apache.hive.service.cli.operation.OperationManager)10 TOperationHandle (org.apache.hive.service.rpc.thrift.TOperationHandle)10 QueryStatus (co.cask.cdap.proto.QueryStatus)7 SQLException (java.sql.SQLException)7 IMetaStoreClient (org.apache.hadoop.hive.metastore.IMetaStoreClient)7 OperationStatus (org.apache.hive.service.cli.OperationStatus)5 TableSchema (org.apache.hive.service.cli.TableSchema)5 Test (org.junit.Test)5 FileNotFoundException (java.io.FileNotFoundException)4 ArrayList (java.util.ArrayList)4 Metrics (org.apache.hadoop.hive.common.metrics.common.Metrics)3 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)3