Skip to content

Commit b3974fc

Browse files
authored
Remove unused Map<String, IndexMode> indexNameWithModes from EsQueryExec and EsSourceExec (#138353)
1 parent 9cd72ee commit b3974fc

File tree

13 files changed

+28
-105
lines changed

13 files changed

+28
-105
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9224000
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
add_downsample_method_telemetry,9223000
1+
esql_es_source_remove_name_with_mods,9224000

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ private static PhysicalPlan rewrite(
124124
queryExec.source(),
125125
queryExec.indexPattern(),
126126
queryExec.indexMode(),
127-
queryExec.indexNameWithModes(),
128127
queryExec.output(),
129128
queryExec.limit(),
130129
queryExec.sorts(),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ private static PhysicalPlan planRoundTo(RoundTo roundTo, EvalExec evalExec, EsQu
342342
queryExec.source(),
343343
queryExec.indexPattern(),
344344
queryExec.indexMode(),
345-
queryExec.indexNameWithModes(),
346345
newAttributes,
347346
queryExec.limit(),
348347
queryExec.sorts(),

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ protected PhysicalPlan rule(EsSourceExec plan) {
5050
plan.source(),
5151
plan.indexPattern(),
5252
plan.indexMode(),
53-
plan.indexNameWithModes(),
5453
attributes,
5554
null,
5655
null,

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/EsQueryExec.java

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class EsQueryExec extends LeafExec implements EstimatesRowSize {
4747

4848
private final String indexPattern;
4949
private final IndexMode indexMode;
50-
private final Map<String, IndexMode> indexNameWithModes;
5150
private final List<Attribute> attrs;
5251
private final Expression limit;
5352
private final List<Sort> sorts;
@@ -141,7 +140,6 @@ public EsQueryExec(
141140
Source source,
142141
String indexPattern,
143142
IndexMode indexMode,
144-
Map<String, IndexMode> indexNameWithModes,
145143
List<Attribute> attrs,
146144
Expression limit,
147145
List<Sort> sorts,
@@ -151,7 +149,6 @@ public EsQueryExec(
151149
super(source);
152150
this.indexPattern = indexPattern;
153151
this.indexMode = indexMode;
154-
this.indexNameWithModes = indexNameWithModes;
155152
this.attrs = attrs;
156153
this.limit = limit;
157154
this.sorts = sorts;
@@ -186,18 +183,7 @@ public boolean hasScoring() {
186183

187184
@Override
188185
protected NodeInfo<EsQueryExec> info() {
189-
return NodeInfo.create(
190-
this,
191-
EsQueryExec::new,
192-
indexPattern,
193-
indexMode,
194-
indexNameWithModes,
195-
attrs,
196-
limit,
197-
sorts,
198-
estimatedRowSize,
199-
queryBuilderAndTags
200-
);
186+
return NodeInfo.create(this, EsQueryExec::new, indexPattern, indexMode, attrs, limit, sorts, estimatedRowSize, queryBuilderAndTags);
201187
}
202188

203189
public String indexPattern() {
@@ -208,10 +194,6 @@ public IndexMode indexMode() {
208194
return indexMode;
209195
}
210196

211-
public Map<String, IndexMode> indexNameWithModes() {
212-
return indexNameWithModes;
213-
}
214-
215197
/**
216198
* query is merged into queryBuilderAndTags, keep this method as it is called by many many places in both tests and product code.
217199
* If this method is called, the caller looks for the original queryBuilder, before {@code ReplaceRoundToWithQueryAndTags} converts it
@@ -260,23 +242,13 @@ public PhysicalPlan estimateRowSize(State state) {
260242
}
261243
return Objects.equals(this.estimatedRowSize, size)
262244
? this
263-
: new EsQueryExec(source(), indexPattern, indexMode, indexNameWithModes, attrs, limit, sorts, size, queryBuilderAndTags);
245+
: new EsQueryExec(source(), indexPattern, indexMode, attrs, limit, sorts, size, queryBuilderAndTags);
264246
}
265247

266248
public EsQueryExec withLimit(Expression limit) {
267249
return Objects.equals(this.limit, limit)
268250
? this
269-
: new EsQueryExec(
270-
source(),
271-
indexPattern,
272-
indexMode,
273-
indexNameWithModes,
274-
attrs,
275-
limit,
276-
sorts,
277-
estimatedRowSize,
278-
queryBuilderAndTags
279-
);
251+
: new EsQueryExec(source(), indexPattern, indexMode, attrs, limit, sorts, estimatedRowSize, queryBuilderAndTags);
280252
}
281253

282254
public boolean canPushSorts() {
@@ -290,17 +262,7 @@ public EsQueryExec withSorts(List<Sort> sorts) {
290262
}
291263
return Objects.equals(this.sorts, sorts)
292264
? this
293-
: new EsQueryExec(
294-
source(),
295-
indexPattern,
296-
indexMode,
297-
indexNameWithModes,
298-
attrs,
299-
limit,
300-
sorts,
301-
estimatedRowSize,
302-
queryBuilderAndTags
303-
);
265+
: new EsQueryExec(source(), indexPattern, indexMode, attrs, limit, sorts, estimatedRowSize, queryBuilderAndTags);
304266
}
305267

306268
/**
@@ -316,7 +278,6 @@ public EsQueryExec withQuery(QueryBuilder query) {
316278
source(),
317279
indexPattern,
318280
indexMode,
319-
indexNameWithModes,
320281
attrs,
321282
limit,
322283
sorts,
@@ -362,7 +323,7 @@ private QueryBuilder queryWithoutTag() {
362323

363324
@Override
364325
public int hashCode() {
365-
return Objects.hash(indexPattern, indexMode, indexNameWithModes, attrs, limit, sorts, queryBuilderAndTags);
326+
return Objects.hash(indexPattern, indexMode, attrs, limit, sorts, queryBuilderAndTags);
366327
}
367328

368329
@Override
@@ -378,7 +339,6 @@ public boolean equals(Object obj) {
378339
EsQueryExec other = (EsQueryExec) obj;
379340
return Objects.equals(indexPattern, other.indexPattern)
380341
&& Objects.equals(indexMode, other.indexMode)
381-
&& Objects.equals(indexNameWithModes, other.indexNameWithModes)
382342
&& Objects.equals(attrs, other.attrs)
383343
&& Objects.equals(limit, other.limit)
384344
&& Objects.equals(sorts, other.sorts)

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/physical/EsSourceExec.java

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package org.elasticsearch.xpack.esql.plan.physical;
99

10+
import org.elasticsearch.TransportVersion;
1011
import org.elasticsearch.TransportVersions;
1112
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
1213
import org.elasticsearch.common.io.stream.StreamInput;
@@ -27,6 +28,9 @@
2728
import java.util.Objects;
2829

2930
public class EsSourceExec extends LeafExec {
31+
32+
protected static final TransportVersion REMOVE_NAME_WITH_MODS = TransportVersion.fromName("esql_es_source_remove_name_with_mods");
33+
3034
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
3135
PhysicalPlan.class,
3236
"EsSourceExec",
@@ -35,41 +39,34 @@ public class EsSourceExec extends LeafExec {
3539

3640
private final String indexPattern;
3741
private final IndexMode indexMode;
38-
private final Map<String, IndexMode> indexNameWithModes;
3942
private final List<Attribute> attributes;
4043
private final QueryBuilder query;
4144

4245
public EsSourceExec(EsRelation relation) {
43-
this(relation.source(), relation.indexPattern(), relation.indexMode(), relation.indexNameWithModes(), relation.output(), null);
46+
this(relation.source(), relation.indexPattern(), relation.indexMode(), relation.output(), null);
4447
}
4548

46-
public EsSourceExec(
47-
Source source,
48-
String indexPattern,
49-
IndexMode indexMode,
50-
Map<String, IndexMode> indexNameWithModes,
51-
List<Attribute> attributes,
52-
QueryBuilder query
53-
) {
49+
public EsSourceExec(Source source, String indexPattern, IndexMode indexMode, List<Attribute> attributes, QueryBuilder query) {
5450
super(source);
5551
this.indexPattern = indexPattern;
5652
this.indexMode = indexMode;
57-
this.indexNameWithModes = indexNameWithModes;
5853
this.attributes = attributes;
5954
this.query = query;
6055
}
6156

6257
private static EsSourceExec readFrom(StreamInput in) throws IOException {
6358
var source = Source.readFrom((PlanStreamInput) in);
6459
String indexPattern = in.readString();
65-
Map<String, IndexMode> indexNameWithModes = in.readMap(IndexMode::readFrom);
60+
if (in.getTransportVersion().supports(REMOVE_NAME_WITH_MODS) == false) {
61+
in.readMap(IndexMode::readFrom);
62+
}
6663
if (in.getTransportVersion().supports(TransportVersions.V_8_18_0) == false) {
6764
in.readImmutableMap(StreamInput::readString, EsField::readFrom);
6865
}
6966
var attributes = in.readNamedWriteableCollectionAsList(Attribute.class);
7067
var query = in.readOptionalNamedWriteable(QueryBuilder.class);
7168
var indexMode = IndexMode.fromString(in.readString());
72-
return new EsSourceExec(source, indexPattern, indexMode, indexNameWithModes, attributes, query);
69+
return new EsSourceExec(source, indexPattern, indexMode, attributes, query);
7370
}
7471

7572
@Override
@@ -79,7 +76,9 @@ public void writeTo(StreamOutput out) throws IOException {
7976
if (out.getTransportVersion().supports(TransportVersions.V_8_18_0) == false) {
8077
out.writeMap(Map.<String, EsField>of(), (o, x) -> x.writeTo(out));
8178
}
82-
out.writeMap(indexNameWithModes, (o, v) -> IndexMode.writeTo(v, out));
79+
if (out.getTransportVersion().supports(REMOVE_NAME_WITH_MODS) == false) {
80+
out.writeMap(Map.<String, IndexMode>of(), (o, v) -> IndexMode.writeTo(v, out));
81+
}
8382
out.writeNamedWriteableCollection(output());
8483
out.writeOptionalNamedWriteable(query());
8584
out.writeString(indexMode().getName());
@@ -98,10 +97,6 @@ public IndexMode indexMode() {
9897
return indexMode;
9998
}
10099

101-
public Map<String, IndexMode> indexNameWithModes() {
102-
return indexNameWithModes;
103-
}
104-
105100
public QueryBuilder query() {
106101
return query;
107102
}
@@ -113,12 +108,12 @@ public List<Attribute> output() {
113108

114109
@Override
115110
protected NodeInfo<? extends PhysicalPlan> info() {
116-
return NodeInfo.create(this, EsSourceExec::new, indexPattern, indexMode, indexNameWithModes, attributes, query);
111+
return NodeInfo.create(this, EsSourceExec::new, indexPattern, indexMode, attributes, query);
117112
}
118113

119114
@Override
120115
public int hashCode() {
121-
return Objects.hash(indexPattern, indexMode, indexNameWithModes, attributes, query);
116+
return Objects.hash(indexPattern, indexMode, attributes, query);
122117
}
123118

124119
@Override
@@ -134,7 +129,6 @@ public boolean equals(Object obj) {
134129
EsSourceExec other = (EsSourceExec) obj;
135130
return Objects.equals(indexPattern, other.indexPattern)
136131
&& Objects.equals(indexMode, other.indexMode)
137-
&& Objects.equals(indexNameWithModes, other.indexNameWithModes)
138132
&& Objects.equals(attributes, other.attributes)
139133
&& Objects.equals(query, other.query);
140134
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/planner/PlannerUtils.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,7 @@ public static PhysicalPlan localPlan(
249249
if (filter != null) {
250250
physicalFragment = physicalFragment.transformUp(
251251
EsSourceExec.class,
252-
query -> new EsSourceExec(
253-
Source.EMPTY,
254-
query.indexPattern(),
255-
query.indexMode(),
256-
query.indexNameWithModes(),
257-
query.output(),
258-
filter
259-
)
252+
query -> new EsSourceExec(Source.EMPTY, query.indexPattern(), query.indexMode(), query.output(), filter)
260253
);
261254
}
262255
var localOptimized = physicalOptimizer.localOptimize(physicalFragment);

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

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,14 +3128,7 @@ public void testFieldExtractWithoutSourceAttributes() {
31283128
// Transform the verified plan so that it is invalid (i.e. no source attributes)
31293129
var badPlan = verifiedPlan.transformDown(
31303130
EsQueryExec.class,
3131-
node -> new EsSourceExec(
3132-
node.source(),
3133-
node.indexPattern(),
3134-
IndexMode.STANDARD,
3135-
node.indexNameWithModes(),
3136-
List.of(),
3137-
node.query()
3138-
)
3131+
node -> new EsSourceExec(node.source(), node.indexPattern(), IndexMode.STANDARD, List.of(), node.query())
31393132
);
31403133

31413134
var e = expectThrows(VerificationException.class, () -> testData.physicalOptimizer().verify(badPlan, verifiedPlan.output()));

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/physical/local/PushTopNToSourceTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,6 @@ public TopNExec build() {
604604
Source.EMPTY,
605605
this.index,
606606
indexMode,
607-
Map.of(),
608607
attributes,
609608
null,
610609
List.of(),

0 commit comments

Comments
 (0)