Skip to content

Commit b29fb22

Browse files
Integrate with latest from main and fix merge errors
1 parent 425a733 commit b29fb22

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/ProjectAwayColumns.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.elasticsearch.xpack.esql.rule.Rule;
2525

2626
import java.util.ArrayList;
27-
import java.util.HashSet;
2827
import java.util.List;
2928

3029
import static java.lang.Boolean.FALSE;
@@ -46,7 +45,7 @@ public PhysicalPlan apply(PhysicalPlan plan) {
4645
// and the overall output will not change.
4746
AttributeSet.Builder requiredAttrBuilder = plan.outputSet().asBuilder();
4847

49-
PhysicalPlan planAfter = plan.transformDown(currentPlanNode -> {
48+
return plan.transformDown(currentPlanNode -> {
5049
if (keepTraversing.get() == false) {
5150
return currentPlanNode;
5251
}
@@ -102,7 +101,6 @@ public PhysicalPlan apply(PhysicalPlan plan) {
102101
output = Expressions.asAttributes(fields);
103102
}
104103
// add a logical projection (let the local replanning remove it if needed)
105-
output = reorderOutput(logicalFragment.output(), output);
106104
FragmentExec newChild = new FragmentExec(
107105
Source.EMPTY,
108106
new Project(logicalFragment.source(), logicalFragment, output),
@@ -120,27 +118,5 @@ public PhysicalPlan apply(PhysicalPlan plan) {
120118
}
121119
return currentPlanNode;
122120
});
123-
return planAfter;
124-
}
125-
126-
private List<Attribute> reorderOutput(List<Attribute> expectedOrder, List<Attribute> attributesToSort) {
127-
List<Attribute> output = new ArrayList<>(attributesToSort.size());
128-
// Track which attributes have been added
129-
var added = new HashSet<Attribute>();
130-
131-
// Add attributes in expectedOrder if present in attributesToSort
132-
for (Attribute expected : expectedOrder) {
133-
if (attributesToSort.contains(expected)) {
134-
output.add(expected);
135-
added.add(expected);
136-
}
137-
}
138-
// Add remaining attributes from attributesToSort in their original order
139-
for (Attribute attr : attributesToSort) {
140-
if (added.contains(attr) == false) {
141-
output.add(attr);
142-
}
143-
}
144-
return output;
145121
}
146122
}

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2905,7 +2905,7 @@ public void testPruneRedundantSortClausesUsingAlias() {
29052905
public void testInsist_fieldDoesNotExist_createsUnmappedFieldInRelation() {
29062906
assumeTrue("Requires UNMAPPED FIELDS", EsqlCapabilities.Cap.UNMAPPED_FIELDS.isEnabled());
29072907

2908-
LogicalPlan plan = optimizedPlan("FROM test | INSIST_ foo");
2908+
LogicalPlan plan = optimizedPlan("FROM test | INSIST_\uD83D\uDC14 foo");
29092909

29102910
var project = as(plan, Project.class);
29112911
var limit = as(project.child(), Limit.class);
@@ -2916,7 +2916,7 @@ public void testInsist_fieldDoesNotExist_createsUnmappedFieldInRelation() {
29162916
public void testInsist_multiIndexFieldPartiallyExistsAndIsKeyword_castsAreNotSupported() {
29172917
assumeTrue("Requires UNMAPPED FIELDS", EsqlCapabilities.Cap.UNMAPPED_FIELDS.isEnabled());
29182918

2919-
var plan = planMultiIndex("FROM multi_index | INSIST_ partial_type_keyword");
2919+
var plan = planMultiIndex("FROM multi_index | INSIST_\uD83D\uDC14 partial_type_keyword");
29202920
var project = as(plan, Project.class);
29212921
var limit = as(project.child(), Limit.class);
29222922
var relation = as(limit.child(), EsRelation.class);
@@ -2927,7 +2927,7 @@ public void testInsist_multiIndexFieldPartiallyExistsAndIsKeyword_castsAreNotSup
29272927
public void testInsist_multipleInsistClauses_insistsAreFolded() {
29282928
assumeTrue("Requires UNMAPPED FIELDS", EsqlCapabilities.Cap.UNMAPPED_FIELDS.isEnabled());
29292929

2930-
var plan = planMultiIndex("FROM multi_index | INSIST_ partial_type_keyword | INSIST_ foo");
2930+
var plan = planMultiIndex("FROM multi_index | INSIST_\uD83D\uDC14 partial_type_keyword | INSIST_\uD83D\uDC14 foo");
29312931
var project = as(plan, Project.class);
29322932
var limit = as(project.child(), Limit.class);
29332933
var relation = as(limit.child(), EsRelation.class);

0 commit comments

Comments
 (0)