Skip to content

Commit 08be01c

Browse files
committed
Fix some attr.name() usages that meant field names
1 parent 3988ee1 commit 08be01c

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public FieldAttribute exactAttribute() {
175175
}
176176

177177
private FieldAttribute innerField(EsField type) {
178-
return new FieldAttribute(source(), name(), name() + "." + type.getName(), type, nullable(), id(), synthetic());
178+
return new FieldAttribute(source(), fieldName().string, name() + "." + type.getName(), type, nullable(), id(), synthetic());
179179
}
180180

181181
@Override

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.elasticsearch.transport.TransportService;
7272
import org.elasticsearch.xpack.esql.EsqlIllegalArgumentException;
7373
import org.elasticsearch.xpack.esql.core.expression.Alias;
74+
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
7475
import org.elasticsearch.xpack.esql.core.expression.NamedExpression;
7576
import org.elasticsearch.xpack.esql.core.tree.Source;
7677
import org.elasticsearch.xpack.esql.core.type.DataType;
@@ -415,8 +416,12 @@ private static Operator extractFieldsOperator(
415416
) {
416417
List<ValuesSourceReaderOperator.FieldInfo> fields = new ArrayList<>(extractFields.size());
417418
for (NamedExpression extractField : extractFields) {
418-
BlockLoader loader = shardContext.blockLoader(
419-
extractField instanceof Alias a ? ((NamedExpression) a.child()).name() : extractField.name(),
419+
String fieldName = extractField instanceof FieldAttribute fa ? fa.fieldName().string()
420+
// Cases for Alias and ReferenceAttribute: only required for ENRICH (Alias in case of ENRICH ... WITH x = field)
421+
// (LOOKUP JOIN uses FieldAttributes)
422+
: extractField instanceof Alias a ? ((NamedExpression) a.child()).name()
423+
: extractField.name();
424+
BlockLoader loader = shardContext.blockLoader(fieldName,
420425
extractField.dataType() == DataType.UNSUPPORTED,
421426
MappedFieldType.FieldExtractPreference.NONE
422427
);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ public AttributeSet rightReferences() {
158158
return Expressions.references(config().rightFields());
159159
}
160160

161+
/**
162+
* The output fields obtained from the right child.
163+
*/
161164
public List<Attribute> rightOutputFields() {
162165
AttributeSet leftInputs = left().outputSet();
163166

0 commit comments

Comments
 (0)