Search in sources :

Example 76 with HiveSQLException

use of org.apache.hive.service.cli.HiveSQLException 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 77 with HiveSQLException

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

the class HiveSessionImpl method open.

@Override
public /**
 * Opens a new HiveServer2 session for the client connection.
 * Creates a new SessionState object that will be associated with this HiveServer2 session.
 * When the server executes multiple queries in the same session,
 * this SessionState object is reused across multiple queries.
 * Note that if doAs is true, this call goes through a proxy object,
 * which wraps the method logic in a UserGroupInformation#doAs.
 * That's why it is important to create SessionState here rather than in the constructor.
 */
void open(Map<String, String> sessionConfMap) throws HiveSQLException {
    sessionState = new SessionState(sessionConf, username);
    sessionState.setUserIpAddress(ipAddress);
    sessionState.setIsHiveServerQuery(true);
    sessionState.setForwardedAddresses(SessionManager.getForwardedAddresses());
    sessionState.setIsUsingThriftJDBCBinarySerDe(updateIsUsingThriftJDBCBinarySerDe());
    try {
        if (sessionManager != null) {
            sessionState.setHiveServer2Host(sessionManager.getHiveServer2HostName());
        }
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
    sessionState.setKillQuery(new KillQueryImpl(operationManager));
    SessionState.start(sessionState);
    try {
        sessionState.loadAuxJars();
        sessionState.loadReloadableAuxJars();
    } catch (IOException e) {
        String msg = "Failed to load reloadable jar file path: " + e;
        LOG.error(msg, e);
        throw new HiveSQLException(msg, e);
    }
    try {
        sessionHive = Hive.get(getHiveConf());
    } catch (HiveException e) {
        throw new HiveSQLException("Failed to get metastore connection", e);
    }
    // Process global init file: .hiverc
    processGlobalInitFile();
    // Set fetch size in session conf map
    sessionConfMap = setFetchSize(sessionConfMap);
    if (sessionConfMap != null) {
        configureSession(sessionConfMap);
    }
    lastAccessTime = System.currentTimeMillis();
}
Also used : SessionState(org.apache.hadoop.hive.ql.session.SessionState) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) KillQueryImpl(org.apache.hive.service.server.KillQueryImpl) IOException(java.io.IOException) MetaException(org.apache.hadoop.hive.metastore.api.MetaException) HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) IOException(java.io.IOException)

Example 78 with HiveSQLException

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

the class HiveSessionImplwithUGI method cancelDelegationToken.

// If the session has a delegation token obtained from the metastore, then cancel it
private void cancelDelegationToken() throws HiveSQLException {
    if (hmsDelegationTokenStr != null) {
        try {
            Hive.get(getHiveConf()).cancelDelegationToken(hmsDelegationTokenStr);
            hmsDelegationTokenStr = null;
            getHiveConf().setVar(HiveConf.ConfVars.METASTORE_TOKEN_SIGNATURE, "");
        } catch (HiveException e) {
            throw new HiveSQLException("Couldn't cancel delegation token", e);
        }
    }
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException)

Example 79 with HiveSQLException

use of org.apache.hive.service.cli.HiveSQLException 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 80 with HiveSQLException

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

the class ThriftCLIServiceClient method getTables.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getTables(org.apache.hive.service.cli.SessionHandle, java.lang.String, java.lang.String, java.lang.String, java.util.List)
   */
@Override
public OperationHandle getTables(SessionHandle sessionHandle, String catalogName, String schemaName, String tableName, List<String> tableTypes) throws HiveSQLException {
    try {
        TGetTablesReq req = new TGetTablesReq(sessionHandle.toTSessionHandle());
        req.setTableName(tableName);
        req.setTableTypes(tableTypes);
        req.setSchemaName(schemaName);
        TGetTablesResp resp = cliService.GetTables(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 : TGetTablesResp(org.apache.hive.service.rpc.thrift.TGetTablesResp) TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TGetTablesReq(org.apache.hive.service.rpc.thrift.TGetTablesReq) 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)

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