Search in sources :

Example 46 with HiveSQLException

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

the class ThriftCLIServiceClient method getCatalogs.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getCatalogs(org.apache.hive.service.cli.SessionHandle)
   */
@Override
public OperationHandle getCatalogs(SessionHandle sessionHandle) throws HiveSQLException {
    try {
        TGetCatalogsReq req = new TGetCatalogsReq(sessionHandle.toTSessionHandle());
        TGetCatalogsResp resp = cliService.GetCatalogs(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 : TGetCatalogsReq(org.apache.hive.service.rpc.thrift.TGetCatalogsReq) TProtocolVersion(org.apache.hive.service.rpc.thrift.TProtocolVersion) 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) TGetCatalogsResp(org.apache.hive.service.rpc.thrift.TGetCatalogsResp)

Example 47 with HiveSQLException

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

the class ThriftCLIServiceClient method cancelOperation.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#cancelOperation(org.apache.hive.service.cli.OperationHandle)
   */
@Override
public void cancelOperation(OperationHandle opHandle) throws HiveSQLException {
    try {
        TCancelOperationReq req = new TCancelOperationReq(opHandle.toTOperationHandle());
        TCancelOperationResp resp = cliService.CancelOperation(req);
        checkStatus(resp.getStatus());
    } catch (HiveSQLException e) {
        throw e;
    } catch (Exception e) {
        throw new HiveSQLException(e);
    }
}
Also used : TCancelOperationReq(org.apache.hive.service.rpc.thrift.TCancelOperationReq) TCancelOperationResp(org.apache.hive.service.rpc.thrift.TCancelOperationResp) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) TException(org.apache.thrift.TException)

Example 48 with HiveSQLException

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

the class ThriftCLIServiceClient method getFunctions.

/* (non-Javadoc)
   * @see org.apache.hive.service.cli.ICLIService#getFunctions(org.apache.hive.service.cli.SessionHandle)
   */
@Override
public OperationHandle getFunctions(SessionHandle sessionHandle, String catalogName, String schemaName, String functionName) throws HiveSQLException {
    try {
        TGetFunctionsReq req = new TGetFunctionsReq(sessionHandle.toTSessionHandle(), functionName);
        req.setCatalogName(catalogName);
        req.setSchemaName(schemaName);
        TGetFunctionsResp resp = cliService.GetFunctions(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) TGetFunctionsResp(org.apache.hive.service.rpc.thrift.TGetFunctionsResp) TGetFunctionsReq(org.apache.hive.service.rpc.thrift.TGetFunctionsReq) 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 49 with HiveSQLException

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

the class KillQueryImpl method killQuery.

@Override
public void killQuery(String queryId, String errMsg) throws HiveException {
    try {
        Operation operation = operationManager.getOperationByQueryId(queryId);
        if (operation == null) {
            LOG.info("Query not found: " + queryId);
        } else {
            OperationHandle handle = operation.getHandle();
            operationManager.cancelOperation(handle, errMsg);
        }
    } catch (HiveSQLException e) {
        throw new HiveException(e);
    }
}
Also used : HiveException(org.apache.hadoop.hive.ql.metadata.HiveException) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) Operation(org.apache.hive.service.cli.operation.Operation) OperationHandle(org.apache.hive.service.cli.OperationHandle)

Example 50 with HiveSQLException

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

the class TestHiveServer2SessionTimeout method testConnection.

@Test
public void testConnection() throws Exception {
    CLIServiceClient serviceClient = miniHS2.getServiceClient();
    SessionHandle sessHandle = serviceClient.openSession("foo", "bar");
    OperationHandle handle = serviceClient.executeStatement(sessHandle, "SELECT 1", confOverlay);
    Thread.sleep(7000);
    try {
        serviceClient.closeOperation(handle);
        fail("Operation should have been closed by timeout!");
    } catch (HiveSQLException e) {
        assertTrue(StringUtils.stringifyException(e), e.getMessage().contains("Invalid OperationHandle"));
    }
}
Also used : CLIServiceClient(org.apache.hive.service.cli.CLIServiceClient) HiveSQLException(org.apache.hive.service.cli.HiveSQLException) SessionHandle(org.apache.hive.service.cli.SessionHandle) OperationHandle(org.apache.hive.service.cli.OperationHandle) Test(org.junit.Test)

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