diff --git a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java index 463057d94054a..1af98f4b21dc5 100644 --- a/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java +++ b/x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/expression/Attribute.java @@ -134,14 +134,4 @@ public String nodeString() { } protected abstract String label(); - - /** - * If this field is unsupported this contains the underlying ES types. If there - * is a type conflict this will have many elements, some or all of which may - * be actually supported types. - */ - @Nullable - public List originalTypes() { - return null; - } } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java index 945117032a5fd..6bfa5a95f5051 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/UnsupportedAttribute.java @@ -174,7 +174,10 @@ protected boolean innerEquals(Object o) { return super.innerEquals(other) && hasCustomMessage == other.hasCustomMessage && Objects.equals(message, other.message); } - @Override + /** + * This contains all the underlying ES types. + * On a type conflict this will have many elements, some or all of which may be actually supported types. + */ public List originalTypes() { return field().getOriginalTypes(); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/TransportEsqlQueryAction.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/TransportEsqlQueryAction.java index 0404f7291fe18..ab96b0505477d 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/TransportEsqlQueryAction.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/TransportEsqlQueryAction.java @@ -50,6 +50,7 @@ import org.elasticsearch.xpack.esql.enrich.EnrichPolicyResolver; import org.elasticsearch.xpack.esql.enrich.LookupFromIndexService; import org.elasticsearch.xpack.esql.execution.PlanExecutor; +import org.elasticsearch.xpack.esql.expression.function.UnsupportedAttribute; import org.elasticsearch.xpack.esql.inference.InferenceRunner; import org.elasticsearch.xpack.esql.session.Configuration; import org.elasticsearch.xpack.esql.session.EsqlSession.PlanRunner; @@ -324,12 +325,12 @@ private EsqlExecutionInfo createEsqlExecutionInfo(EsqlQueryRequest request) { private EsqlQueryResponse toResponse(Task task, EsqlQueryRequest request, Configuration configuration, Result result) { List columns = result.schema().stream().map(c -> { List originalTypes; - if (c.originalTypes() == null) { - originalTypes = null; - } else { + if (c instanceof UnsupportedAttribute ua) { // Sort the original types so they are easier to test against and prettier. - originalTypes = new ArrayList<>(c.originalTypes()); + originalTypes = new ArrayList<>(ua.originalTypes()); Collections.sort(originalTypes); + } else { + originalTypes = null; } return new ColumnInfoImpl(c.name(), c.dataType().outputType(), originalTypes); }).toList();