Skip to content

Commit c4cc4df

Browse files
committed
Move originalTypes method to FieldAttribute
This moves originalTypes() from Attribute to FieldAttribute, since only a FieldAttribute (and its subclasses) can refer to a field with multiple types.
1 parent 9e3476e commit c4cc4df

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,4 @@ public String nodeString() {
134134
}
135135

136136
protected abstract String label();
137-
138-
/**
139-
* If this field is unsupported this contains the underlying ES types. If there
140-
* is a type conflict this will have many elements, some or all of which may
141-
* be actually supported types.
142-
*/
143-
@Nullable
144-
public List<String> originalTypes() {
145-
return null;
146-
}
147137
}

x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/FieldAttribute.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.xpack.esql.core.util.PlanStreamOutput;
2121

2222
import java.io.IOException;
23+
import java.util.List;
2324
import java.util.Objects;
2425

2526
import static org.elasticsearch.xpack.esql.core.util.PlanStreamInput.readCachedStringWithVersionCheck;
@@ -242,4 +243,14 @@ protected String label() {
242243
public EsField field() {
243244
return field;
244245
}
246+
247+
/**
248+
* If this field is unsupported this contains the underlying ES types. If there
249+
* is a type conflict this will have many elements, some or all of which may
250+
* be actually supported types.
251+
*/
252+
@Nullable
253+
public List<String> originalTypes() {
254+
return null;
255+
}
245256
}

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import org.elasticsearch.xpack.esql.action.EsqlQueryResponse;
4444
import org.elasticsearch.xpack.esql.action.EsqlQueryTask;
4545
import org.elasticsearch.xpack.esql.core.async.AsyncTaskManagementService;
46+
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
4647
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
4748
import org.elasticsearch.xpack.esql.enrich.AbstractLookupService;
4849
import org.elasticsearch.xpack.esql.enrich.EnrichLookupService;
@@ -321,12 +322,12 @@ private EsqlExecutionInfo createEsqlExecutionInfo(EsqlQueryRequest request) {
321322
private EsqlQueryResponse toResponse(Task task, EsqlQueryRequest request, Configuration configuration, Result result) {
322323
List<ColumnInfoImpl> columns = result.schema().stream().map(c -> {
323324
List<String> originalTypes;
324-
if (c.originalTypes() == null) {
325-
originalTypes = null;
326-
} else {
325+
if (c instanceof FieldAttribute fa && (originalTypes = fa.originalTypes()) != null) {
327326
// Sort the original types so they are easier to test against and prettier.
328-
originalTypes = new ArrayList<>(c.originalTypes());
327+
originalTypes = new ArrayList<>(originalTypes);
329328
Collections.sort(originalTypes);
329+
} else {
330+
originalTypes = null;
330331
}
331332
return new ColumnInfoImpl(c.name(), c.dataType().outputType(), originalTypes);
332333
}).toList();

0 commit comments

Comments
 (0)