Skip to content

Commit

Permalink
Refactor DatabaseConnector (#32448)
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu authored Aug 9, 2024
1 parent 7433bcb commit 8c40d61
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ private ResponseHeader doExecute(final ExecutionContext executionContext) throws
return new UpdateResponseHeader(queryContext.getSqlStatementContext().getSqlStatement());
}
proxySQLExecutor.checkExecutePrerequisites(executionContext);
List<ExecuteResult> result = proxySQLExecutor.execute(executionContext);
refreshMetaData(executionContext);
Object executeResultSample = result.iterator().next();
List<ExecuteResult> executeResults = proxySQLExecutor.execute(executionContext);
getMetaDataRefreshEngine().refresh(queryContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits());
Object executeResultSample = executeResults.iterator().next();
return executeResultSample instanceof QueryResult
? processExecuteQuery(queryContext.getSqlStatementContext(), result.stream().map(QueryResult.class::cast).collect(Collectors.toList()), (QueryResult) executeResultSample)
: processExecuteUpdate(result.stream().map(UpdateResult.class::cast).collect(Collectors.toList()));
? processExecuteQuery(queryContext.getSqlStatementContext(), executeResults.stream().map(QueryResult.class::cast).collect(Collectors.toList()), (QueryResult) executeResultSample)
: processExecuteUpdate(executeResults.stream().map(UpdateResult.class::cast).collect(Collectors.toList()));
}

private ResultSet doExecuteFederation() {
Expand Down Expand Up @@ -275,10 +275,6 @@ private ResponseHeader processExecuteFederation(final ResultSet resultSet) throw
return new QueryResponseHeader(queryHeaders);
}

private void refreshMetaData(final ExecutionContext executionContext) throws SQLException {
getMetaDataRefreshEngine().refresh(queryContext.getSqlStatementContext(), executionContext.getRouteContext().getRouteUnits());
}

private MetaDataRefreshEngine getMetaDataRefreshEngine() {
return new MetaDataRefreshEngine(contextManager.getPersistServiceFacade().getMetaDataManagerPersistService(), database, contextManager.getMetaDataContexts().getMetaData().getProps());
}
Expand Down

0 comments on commit 8c40d61

Please sign in to comment.