public void cancelDelegationToken(String tokenStr) throws SQLException { TCancelDelegationTokenReq cancelReq = new TCancelDelegationTokenReq(sessHandle, tokenStr); try { TCancelDelegationTokenResp cancelResp = client.CancelDelegationToken(cancelReq); Utils.verifySuccess(cancelResp.getStatus()); return; } catch (TException e) { throw new SQLException("Could not cancel token: " + e.getMessage(), " 08S01", e); } }
@Override public void cancel() throws SQLException { checkConnection("cancel"); if (isCancelled) { return; } try { if (stmtHandle != null) { TCancelOperationReq cancelReq = new TCancelOperationReq(stmtHandle); TCancelOperationResp cancelResp = client.CancelOperation(cancelReq); Utils.verifySuccessWithInfo(cancelResp.getStatus()); } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException(e.toString(), "08S01", e); } isCancelled = true; }
/** * Closes the statement if there is one running. Do not change the the flags. * @throws SQLException If there is an error closing the statement */ private void closeStatementIfNeeded() throws SQLException { try { if (stmtHandle != null) { TCloseOperationReq closeReq = new TCloseOperationReq(stmtHandle); TCloseOperationResp closeResp = client.CloseOperation(closeReq); Utils.verifySuccessWithInfo(closeResp.getStatus()); stmtHandle = null; } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException(e.toString(), "08S01", e); } }
orientation, fetchSize); TFetchResultsResp fetchResp; fetchResp = client.FetchResults(fetchReq); Utils.verifySuccessWithInfo(fetchResp.getStatus());
getFetchOrientation(incremental), fetchSize); tFetchResultsReq.setFetchType((short)1); tFetchResultsResp = client.FetchResults(tFetchResultsReq); Utils.verifySuccessWithInfo(tFetchResultsResp.getStatus()); } else {
private void runAsyncOnServer(String sql) throws SQLException { checkConnection("execute"); reInitState(); TExecuteStatementReq execReq = new TExecuteStatementReq(sessHandle, sql); /** * Run asynchronously whenever possible * Currently only a SQLOperation can be run asynchronously, * in a background operation thread * Compilation can run asynchronously or synchronously and execution run asynchronously */ execReq.setRunAsync(true); execReq.setConfOverlay(sessConf); execReq.setQueryTimeout(queryTimeout); try { TExecuteStatementResp execResp = client.ExecuteStatement(execReq); Utils.verifySuccessWithInfo(execResp.getStatus()); stmtHandle = execResp.getOperationHandle(); isExecuteStatementFailed = false; } catch (SQLException eS) { isExecuteStatementFailed = true; isLogBeingGenerated = false; throw eS; } catch (Exception ex) { isExecuteStatementFailed = true; isLogBeingGenerated = false; throw new SQLException(ex.toString(), "08S01", ex); } }
public ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException { TGetCrossReferenceResp getFKResp; TGetCrossReferenceReq getFKReq = new TGetCrossReferenceReq(sessHandle); getFKReq.setParentTableName(primaryTable); getFKReq.setParentSchemaName(primarySchema); getFKReq.setParentCatalogName(primaryCatalog); getFKReq.setForeignTableName(foreignTable); getFKReq.setForeignSchemaName(foreignSchema); getFKReq.setForeignCatalogName(foreignCatalog); try { getFKResp = client.GetCrossReference(getFKReq); } catch (TException e) { throw new SQLException(e.getMessage(), "08S01", e); } Utils.verifySuccess(getFKResp.getStatus()); return new HiveQueryResultSet.Builder(connection) .setClient(client) .setSessionHandle(sessHandle) .setStmtHandle(getFKResp.getOperationHandle()) .build(); }
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { TGetColumnsResp colResp; TGetColumnsReq colReq = new TGetColumnsReq(); colReq.setSessionHandle(sessHandle); colReq.setCatalogName(catalog); colReq.setSchemaName(schemaPattern); colReq.setTableName(tableNamePattern); colReq.setColumnName(columnNamePattern); try { colResp = client.GetColumns(colReq); } catch (TException e) { throw new SQLException(e.getMessage(), "08S01", e); } Utils.verifySuccess(colResp.getStatus()); // build the resultset from response return new HiveQueryResultSet.Builder(connection) .setClient(client) .setSessionHandle(sessHandle) .setStmtHandle(colResp.getOperationHandle()) .build(); }
@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); } }
@Override public OperationHandle getColumns(SessionHandle sessionHandle, String catalogName, String schemaName, String tableName, String columnName) throws HiveSQLException { try { TGetColumnsReq req = new TGetColumnsReq(); req.setSessionHandle(sessionHandle.toTSessionHandle()); req.setCatalogName(catalogName); req.setSchemaName(schemaName); req.setTableName(tableName); req.setColumnName(columnName); TGetColumnsResp resp = cliService.GetColumns(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 void cancel() throws SQLException { checkConnection("cancel"); if (isCancelled) { return; } try { if (stmtHandle != null) { TCancelOperationReq cancelReq = new TCancelOperationReq(stmtHandle); TCancelOperationResp cancelResp = client.CancelOperation(cancelReq); Utils.verifySuccessWithInfo(cancelResp.getStatus()); } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException(e.toString(), "08S01", e); } isCancelled = true; }
@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); } }
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); } }
/** * Closes the statement if there is one running. Do not change the the flags. * @throws SQLException If there is an error closing the statement */ private void closeStatementIfNeeded() throws SQLException { try { if (stmtHandle != null) { TCloseOperationReq closeReq = new TCloseOperationReq(stmtHandle); TCloseOperationResp closeResp = client.CloseOperation(closeReq); Utils.verifySuccessWithInfo(closeResp.getStatus()); stmtHandle = null; } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException(e.toString(), "08S01", e); } }
@Override public void close() throws SQLException { if (!isClosed) { TCloseSessionReq closeReq = new TCloseSessionReq(sessHandle); try { client.CloseSession(closeReq); } catch (TException e) { throw new SQLException("Error while cleaning up the server resources", e); } finally { isClosed = true; if (transport != null) { transport.close(); } } } }
@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); } }
public ResultSet getCatalogs() throws SQLException { TGetCatalogsResp catalogResp; try { catalogResp = client.GetCatalogs(new TGetCatalogsReq(sessHandle)); } catch (TException e) { throw new SQLException(e.getMessage(), "08S01", e); } Utils.verifySuccess(catalogResp.getStatus()); return new HiveQueryResultSet.Builder(connection) .setClient(client) .setSessionHandle(sessHandle) .setStmtHandle(catalogResp.getOperationHandle()) .build(); }
private void closeOperationHandle(TOperationHandle stmtHandle) throws SQLException { try { if (stmtHandle != null) { TCloseOperationReq closeReq = new TCloseOperationReq(stmtHandle); TCloseOperationResp closeResp = client.CloseOperation(closeReq); Utils.verifySuccessWithInfo(closeResp.getStatus()); } } catch (SQLException e) { throw e; } catch (Exception e) { throw new SQLException(e.toString(), "08S01", 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); } }