Skip to content

Commit ed0a9ce

Browse files
authored
Remove unused code (#138183)
1 parent 280e5b6 commit ed0a9ce

File tree

3 files changed

+13
-49
lines changed

3 files changed

+13
-49
lines changed

x-pack/plugin/esql/qa/testFixtures/src/main/java/org/elasticsearch/xpack/esql/EsqlTestUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,8 @@ public static EsRelation relation() {
324324
}
325325

326326
public static EsRelation relation(IndexMode mode) {
327-
return new EsRelation(EMPTY, new EsIndex(randomAlphaOfLength(8), emptyMap()), mode);
327+
var index = new EsIndex(randomAlphaOfLength(8), emptyMap());
328+
return new EsRelation(EMPTY, index.name(), mode, index.indexNameWithModes(), List.of());
328329
}
329330

330331
/**

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plan/logical/EsRelation.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@
1212
import org.elasticsearch.common.io.stream.StreamOutput;
1313
import org.elasticsearch.index.IndexMode;
1414
import org.elasticsearch.xpack.esql.core.expression.Attribute;
15-
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
1615
import org.elasticsearch.xpack.esql.core.tree.NodeInfo;
1716
import org.elasticsearch.xpack.esql.core.tree.NodeUtils;
1817
import org.elasticsearch.xpack.esql.core.tree.Source;
19-
import org.elasticsearch.xpack.esql.core.type.EsField;
2018
import org.elasticsearch.xpack.esql.index.EsIndex;
2119
import org.elasticsearch.xpack.esql.io.stream.PlanStreamInput;
2220

2321
import java.io.IOException;
24-
import java.util.ArrayList;
2522
import java.util.List;
2623
import java.util.Map;
27-
import java.util.Map.Entry;
2824
import java.util.Objects;
2925
import java.util.Set;
3026

@@ -40,10 +36,6 @@ public class EsRelation extends LeafPlan {
4036
private final Map<String, IndexMode> indexNameWithModes;
4137
private final List<Attribute> attrs;
4238

43-
public EsRelation(Source source, EsIndex index, IndexMode indexMode) {
44-
this(source, index.name(), indexMode, index.indexNameWithModes(), flatten(source, index.mapping()));
45-
}
46-
4739
public EsRelation(
4840
Source source,
4941
String indexPattern,
@@ -104,35 +96,6 @@ protected NodeInfo<EsRelation> info() {
10496
return NodeInfo.create(this, EsRelation::new, indexPattern, indexMode, indexNameWithModes, attrs);
10597
}
10698

107-
private static List<Attribute> flatten(Source source, Map<String, EsField> mapping) {
108-
return flatten(source, mapping, null);
109-
}
110-
111-
private static List<Attribute> flatten(Source source, Map<String, EsField> mapping, FieldAttribute parent) {
112-
List<Attribute> list = new ArrayList<>();
113-
114-
for (Entry<String, EsField> entry : mapping.entrySet()) {
115-
String name = entry.getKey();
116-
EsField t = entry.getValue();
117-
118-
if (t != null) {
119-
FieldAttribute f = new FieldAttribute(
120-
source,
121-
parent != null ? parent.name() : null,
122-
null,
123-
parent != null ? parent.name() + "." + name : name,
124-
t
125-
);
126-
list.add(f);
127-
// object or nested
128-
if (t.getProperties().isEmpty() == false) {
129-
list.addAll(flatten(source, t.getProperties(), f));
130-
}
131-
}
132-
}
133-
return list;
134-
}
135-
13699
public String indexPattern() {
137100
return indexPattern;
138101
}

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
import java.util.Map;
165165
import java.util.Objects;
166166
import java.util.Set;
167+
import java.util.function.Function;
167168
import java.util.regex.Pattern;
168169
import java.util.stream.Collectors;
169170

@@ -3246,18 +3247,17 @@ public void testProjectAwayColumns() {
32463247
// \_FragmentExec[filter=null, estimatedRowSize=0, reducer=[], fragment=[<>
32473248
// EsRelation[test][some_field1{f}#2, some_field2{f}#3]<>]]
32483249

3249-
EsRelation relation = new EsRelation(
3250+
var esField = List.of(
3251+
new EsField("some_field1", DataType.KEYWORD, Map.of(), true, EsField.TimeSeriesFieldType.NONE),
3252+
new EsField("some_field2", DataType.KEYWORD, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
3253+
);
3254+
var index = new EsIndex("test", esField.stream().collect(Collectors.toMap(EsField::getName, Function.identity())));
3255+
var relation = new EsRelation(
32503256
Source.EMPTY,
3251-
new EsIndex(
3252-
"test",
3253-
Map.of(
3254-
"some_field1",
3255-
new EsField("some_field1", DataType.KEYWORD, Map.of(), true, EsField.TimeSeriesFieldType.NONE),
3256-
"some_field2",
3257-
new EsField("some_field2", DataType.KEYWORD, Map.of(), true, EsField.TimeSeriesFieldType.NONE)
3258-
)
3259-
),
3260-
IndexMode.STANDARD
3257+
index.name(),
3258+
IndexMode.STANDARD,
3259+
index.indexNameWithModes(),
3260+
esField.stream().map(field -> (Attribute) new FieldAttribute(Source.EMPTY, null, null, field.getName(), field)).toList()
32613261
);
32623262
Attribute some_field1 = relation.output().get(0);
32633263
Attribute some_field2 = relation.output().get(1);

0 commit comments

Comments
 (0)