-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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
For empty mappings use a LocalRelation #105081
Changes from all commits
8b919c3
89f5c36
1796738
0205667
c5799f2
676331f
e2c08d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 105081 | ||
summary: For empty mappings use a `LocalRelation` | ||
area: ES|QL | ||
type: bug | ||
issues: | ||
- 104809 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,7 +152,8 @@ protected static List<Batch<LogicalPlan>> rules() { | |
// lastly replace surrogate functions | ||
new SubstituteSurrogates(), | ||
new ReplaceRegexMatch(), | ||
new ReplaceAliasingEvalWithProject() | ||
new ReplaceAliasingEvalWithProject(), | ||
new SkipQueryOnEmptyMappings() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not part of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this can be determine upfront, which facilitates the rest of the rules and folding of LocalRelation through-out the plan. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does make the other rules do less work, yes, but since there's a |
||
// new NormalizeAggregate(), - waits on https://github.com/elastic/elasticsearch/issues/100634 | ||
); | ||
|
||
|
@@ -704,6 +705,14 @@ protected LogicalPlan rule(UnaryPlan plan) { | |
} | ||
} | ||
|
||
static class SkipQueryOnEmptyMappings extends OptimizerRules.OptimizerRule<EsRelation> { | ||
|
||
@Override | ||
protected LogicalPlan rule(EsRelation plan) { | ||
return plan.index().concreteIndices().isEmpty() ? new LocalRelation(plan.source(), plan.output(), LocalSupplier.EMPTY) : plan; | ||
} | ||
} | ||
|
||
@SuppressWarnings("removal") | ||
static class PropagateEmptyRelation extends OptimizerRules.OptimizerRule<UnaryPlan> { | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ | |
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import static java.util.Arrays.asList; | ||
|
@@ -143,7 +144,7 @@ public void init() { | |
|
||
private Analyzer makeAnalyzer(String mappingFileName, EnrichResolution enrichResolution) { | ||
var mapping = loadMapping(mappingFileName); | ||
EsIndex test = new EsIndex("test", mapping); | ||
EsIndex test = new EsIndex("test", mapping, Set.of("test")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With all the similar changes to add a concrete index, wondering if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have mixed feelings about this. I know it's not a big deal, but if something is used only in tests, the method/constructor access modifier should reflect this. But this class is used in many different packages and the only possible access modifier is |
||
IndexResolution getIndexResult = IndexResolution.valid(test); | ||
|
||
return new Analyzer(new AnalyzerContext(config, functionRegistry, getIndexResult, enrichResolution), new Verifier(new Metrics())); | ||
|
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.
👍