-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Simplify index pattern #134215
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
Simplify index pattern #134215
Conversation
Pinging @elastic/es-analytical-engine (Team:Analytics) |
ThreadPool.Names.SEARCH_COORDINATION, | ||
ThreadPool.Names.SYSTEM_READ | ||
); | ||
// TODO we plan to support joins in the future when possible, but for now we'll just fail early if we see one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already support lookup joins and they require a separate data structure.
Once we support nested queries they would likely need their own structure (to distinguish top level vs nested query).
Today we are guarded by grammar and parser to never have more than a single item in the list so indices.size() > 1
is effectively a dead code.
listener.onFailure(ex); | ||
} | ||
// occurs when dealing with local relations (row a = 1) | ||
listener.onResponse(result.withIndexResolution(IndexResolution.invalid("[none specified]"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing could be thrown here.
plan.forEachUp(LogicalPlan::setPreAnalyzed); | ||
|
||
return new PreAnalysis(indexMode.get(), indices.stream().toList(), unresolvedEnriches, lookupIndices); | ||
return new PreAnalysis(indexMode.get(), index.get(), unresolvedEnriches, lookupIndices); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like indices
were copied to immutable list here. I wonder if it is worth doing the same for unresolvedEnriches
and lookupIndices
?
plan.forEachUp(UnresolvedRelation.class, p -> { | ||
if (p.indexMode() == IndexMode.LOOKUP) { | ||
lookupIndices.add(p.indexPattern()); | ||
} else if (indexMode.get() == null || indexMode.get() == p.indexMode()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover: In case that we somehow find 2 indices in the same mode, we're going to silently throw away the previous one.
There shouldn't be 2 indices. This is enforced in EsqlSession#preAnalyzeMainIndices
.
IndicesExpressionGrouper indicesGrouper, | ||
XPackLicenseState licenseState, | ||
List<IndexPattern> patterns, | ||
IndexPattern index, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we're moving the naming back to index
, but we know this is generally a pattern. Also applies to PreAnalyzer
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ to what @alex-spies said, the name "index" can be confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, updating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
IndicesExpressionGrouper indicesGrouper, | ||
XPackLicenseState licenseState, | ||
List<IndexPattern> patterns, | ||
IndexPattern index, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ to what @alex-spies said, the name "index" can be confusing.
BASE=c05c61d38cdac9c9608d6e8989f1fa7b9ca035cb HEAD=394aaef8034a4e09c6ef307a5ac9ac5d4f1e3f52 Branch=main
BASE=c05c61d38cdac9c9608d6e8989f1fa7b9ca035cb HEAD=394aaef8034a4e09c6ef307a5ac9ac5d4f1e3f52 Branch=main
BASE=c05c61d38cdac9c9608d6e8989f1fa7b9ca035cb HEAD=394aaef8034a4e09c6ef307a5ac9ac5d4f1e3f52 Branch=main
BASE=c05c61d38cdac9c9608d6e8989f1fa7b9ca035cb HEAD=394aaef8034a4e09c6ef307a5ac9ac5d4f1e3f52 Branch=main
BASE=c05c61d38cdac9c9608d6e8989f1fa7b9ca035cb HEAD=394aaef8034a4e09c6ef307a5ac9ac5d4f1e3f52 Branch=main
We are using
IndexPattern
class to represent a set of patterns inFROM p1,p2
or inLOOKUP JOIN p1
.Today it is impossible to have more than a single
FROM
, however we store main indices patterns in a list that leads to unnecessary complexity.This change replaces list with a nullable field.