@Override public void closeSession(SessionHandle sessionHandle) throws HiveSQLException { try { TCloseSessionReq req = new TCloseSessionReq(sessionHandle.toTSessionHandle()); TCloseSessionResp resp = cliService.CloseSession(req); checkStatus(resp.getStatus()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@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); } }
@Override public void closeOperation(OperationHandle opHandle) throws HiveSQLException { try { TCloseOperationReq req = new TCloseOperationReq(opHandle.toTOperationHandle()); TCloseOperationResp resp = cliService.CloseOperation(req); checkStatus(resp.getStatus()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public void cancelDelegationToken(SessionHandle sessionHandle, HiveAuthFactory authFactory, String tokenStr) throws HiveSQLException { TCancelDelegationTokenReq cancelReq = new TCancelDelegationTokenReq( sessionHandle.toTSessionHandle(), tokenStr); try { TCancelDelegationTokenResp cancelResp = cliService.CancelDelegationToken(cancelReq); checkStatus(cancelResp.getStatus()); return; } catch (TException e) { throw new HiveSQLException(e); } }
@Override public void renewDelegationToken(SessionHandle sessionHandle, HiveAuthFactory authFactory, String tokenStr) throws HiveSQLException { TRenewDelegationTokenReq cancelReq = new TRenewDelegationTokenReq( sessionHandle.toTSessionHandle(), tokenStr); try { TRenewDelegationTokenResp renewResp = cliService.RenewDelegationToken(cancelReq); checkStatus(renewResp.getStatus()); return; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public void setApplicationName(SessionHandle sh, String value) throws HiveSQLException { try { TSetClientInfoReq req = new TSetClientInfoReq(sh.toTSessionHandle()); req.putToConfiguration("ApplicationName", value); TSetClientInfoResp resp = cliService.SetClientInfo(req); checkStatus(resp.getStatus()); } catch (TException e) { throw new HiveSQLException(e); } } }
@Override public String getDelegationToken(SessionHandle sessionHandle, HiveAuthFactory authFactory, String owner, String renewer) throws HiveSQLException { TGetDelegationTokenReq req = new TGetDelegationTokenReq( sessionHandle.toTSessionHandle(), owner, renewer); try { TGetDelegationTokenResp tokenResp = cliService.GetDelegationToken(req); checkStatus(tokenResp.getStatus()); return tokenResp.getDelegationToken(); } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public TableSchema getResultSetMetadata(OperationHandle opHandle) throws HiveSQLException { try { TGetResultSetMetadataReq req = new TGetResultSetMetadataReq(opHandle.toTOperationHandle()); TGetResultSetMetadataResp resp = cliService.GetResultSetMetadata(req); checkStatus(resp.getStatus()); return new TableSchema(resp.getSchema()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public OperationHandle getTableTypes(SessionHandle sessionHandle) throws HiveSQLException { try { TGetTableTypesReq req = new TGetTableTypesReq(sessionHandle.toTSessionHandle()); TGetTableTypesResp resp = cliService.GetTableTypes(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); } }
@Override public OperationHandle getTypeInfo(SessionHandle sessionHandle) throws HiveSQLException { try { TGetTypeInfoReq req = new TGetTypeInfoReq(sessionHandle.toTSessionHandle()); TGetTypeInfoResp resp = cliService.GetTypeInfo(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); } }
@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); } }
@Override public GetInfoValue getInfo(SessionHandle sessionHandle, GetInfoType infoType) throws HiveSQLException { try { // FIXME extract the right info type TGetInfoReq req = new TGetInfoReq(sessionHandle.toTSessionHandle(), infoType.toTGetInfoType()); TGetInfoResp resp = cliService.GetInfo(req); checkStatus(resp.getStatus()); return new GetInfoValue(resp.getInfoValue()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public SessionHandle openSession(String username, String password, Map<String, String> configuration) throws HiveSQLException { try { TOpenSessionReq req = new TOpenSessionReq(); req.setUsername(username); req.setPassword(password); req.setConfiguration(configuration); TOpenSessionResp resp = cliService.OpenSession(req); checkStatus(resp.getStatus()); return new SessionHandle(resp.getSessionHandle(), resp.getServerProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@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); } }
@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); } }
@Override public OperationHandle getPrimaryKeys(SessionHandle sessionHandle, String catalog, String schema, String table) throws HiveSQLException { try { TGetPrimaryKeysReq req = new TGetPrimaryKeysReq(sessionHandle.toTSessionHandle()); req.setCatalogName(catalog); req.setSchemaName(schema); req.setTableName(table); TGetPrimaryKeysResp resp = cliService.GetPrimaryKeys(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); } }
private OperationHandle executeStatementInternal(SessionHandle sessionHandle, String statement, Map<String, String> confOverlay, boolean isAsync, long queryTimeout) throws HiveSQLException { try { TExecuteStatementReq req = new TExecuteStatementReq(sessionHandle.toTSessionHandle(), statement); req.setConfOverlay(confOverlay); req.setRunAsync(isAsync); req.setQueryTimeout(queryTimeout); TExecuteStatementResp resp = cliService.ExecuteStatement(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); } }
@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); } }
@Override public RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation, long maxRows, FetchType fetchType) throws HiveSQLException { try { TFetchResultsReq req = new TFetchResultsReq(); req.setOperationHandle(opHandle.toTOperationHandle()); req.setOrientation(orientation.toTFetchOrientation()); req.setMaxRows(maxRows); req.setFetchType(fetchType.toTFetchType()); TFetchResultsResp resp = cliService.FetchResults(req); checkStatus(resp.getStatus()); return RowSetFactory.create(resp.getResults(), opHandle.getProtocolVersion()); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }
@Override public OperationStatus getOperationStatus(OperationHandle opHandle, boolean getProgressUpdate) throws HiveSQLException { try { TGetOperationStatusReq req = new TGetOperationStatusReq(opHandle.toTOperationHandle()); req.setGetProgressUpdate(getProgressUpdate); TGetOperationStatusResp resp = cliService.GetOperationStatus(req); // Checks the status of the RPC call, throws an exception in case of error checkStatus(resp.getStatus()); OperationState opState = OperationState.getOperationState(resp.getOperationState()); HiveSQLException opException = null; if (opState == OperationState.ERROR) { opException = new HiveSQLException(resp.getErrorMessage(), resp.getSqlState(), resp.getErrorCode()); } return new OperationStatus(opState, resp.getTaskStatus(), resp.getOperationStarted(), resp.getOperationCompleted(), resp.isSetHasResultSet() ? resp.isHasResultSet() : null, opException); } catch (HiveSQLException e) { throw e; } catch (Exception e) { throw new HiveSQLException(e); } }