Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CCS handling code from EsqlSession and IndexResolver into dedicated util class #115976

Closed
wants to merge 5 commits into from

Conversation

quux00
Copy link
Contributor

@quux00 quux00 commented Oct 30, 2024

This a pure refactoring ticket. No new functionality was added.
A few new tests were added since they are exposed in a place for easier testing.
Based on #115266 (review)

@quux00 quux00 added >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) auto-backport Automatically create backport pull requests when merged :Analytics/ES|QL AKA ESQL v9.0.0 v8.17.0 labels Oct 30, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@quux00 quux00 force-pushed the esql/refactor-ccs-EsqlSession branch from 9bb8af3 to 84163d8 Compare October 30, 2024 19:21
null
);
ActionListener.wrap(plan -> executeOptimizedPlan(request, executionInfo, runPhase, optimizedPlan(plan), listener), e -> {
if (EsqlSessionCCSUtils.returnSuccessWithEmptyResult(executionInfo, e)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could go further and put this logic into EsqlSessionCCSUtils too. So we'd have just a method name here. After all, creating an empty result is also a generic function that is not very specific to EsqlSession?

EsqlExecutionInfo.Cluster cluster = executionInfo.getCluster(clusterAlias);
if (cluster.getStatus() != EsqlExecutionInfo.Cluster.Status.SKIPPED) {
if (cluster.getClusterAlias().equals(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY)) {
sb.append(executionInfo.getCluster(clusterAlias).getIndexExpression()).append(',');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executionInfo.getCluster(clusterAlias).getIndexExpression() is called in both the if branches. I wonder if it'd be better to pull it out?

}
}

if (sb.length() > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: use isEmpty()?

Comment on lines +164 to +170
for (String clusterAlias : executionInfo.clusterAliases()) {
if (executionInfo.isSkipUnavailable(clusterAlias) == false
&& clusterAlias.equals(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY) == false) {
return false;
}
}
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's your opinion on writing this as:

return executionInfo.clusterAliases()
    .stream()
    .noneMatch(clusterAlias -> executionInfo.isSkipUnavailable(clusterAlias) == false && clusterAlias.equals(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY) == false
);

@quux00
Copy link
Contributor Author

quux00 commented Oct 31, 2024

This refactoring overlaps a lot of the refactoring Costin did in his PR around lookups: #115813 (review)

so probably makes sense to close this PR and wait for his to merge.

@quux00
Copy link
Contributor Author

quux00 commented Oct 31, 2024

Closing since Costin has done much of this refactoring in #115813.
I will address a few other minor refactorings not included in his PR in my next ticket around CCS ESQL skip_unavailable.

@quux00 quux00 closed this Oct 31, 2024
quux00 added a commit to quux00/elasticsearch that referenced this pull request Nov 1, 2024
quux00 added a commit to quux00/elasticsearch that referenced this pull request Nov 1, 2024
quux00 added a commit that referenced this pull request Nov 2, 2024
quux00 added a commit to quux00/elasticsearch that referenced this pull request Nov 2, 2024
quux00 added a commit to quux00/elasticsearch that referenced this pull request Nov 2, 2024
elasticsearchmachine pushed a commit that referenced this pull request Nov 3, 2024
* Finalized refactorings from closed PR #115976 (#116121)

Pure refactoring PR

* Muting tests that are muted on main but not 8.x so I can get the backport to succeed

* Muting tests that are muted on main but not 8.x so I can get the backport to succeed, part 2
jfreden pushed a commit to jfreden/elasticsearch that referenced this pull request Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged >refactoring Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.17.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants