Skip to content

Commit 44dca94

Browse files
committed
Allow union type fields to be match fields
In LOOKUP JOIN, union type fields don't work as match fields because we extract their names wrong. Correct this and make MatchConfig rely on FieldName to avoid this problem going forward.
1 parent 08be01c commit 44dca94

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.elasticsearch.core.Releasables;
2424
import org.elasticsearch.tasks.CancellableTask;
2525
import org.elasticsearch.xcontent.XContentBuilder;
26+
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
2627
import org.elasticsearch.xpack.esql.core.expression.NamedExpression;
2728
import org.elasticsearch.xpack.esql.core.tree.Source;
2829
import org.elasticsearch.xpack.esql.core.type.DataType;
@@ -45,7 +46,7 @@ public record Factory(
4546
DataType inputDataType,
4647
String lookupIndexPattern,
4748
String lookupIndex,
48-
String matchField,
49+
FieldAttribute.FieldName matchField,
4950
List<NamedExpression> loadFields,
5051
Source source
5152
) implements OperatorFactory {
@@ -56,7 +57,7 @@ public String describe() {
5657
+ " input_type="
5758
+ inputDataType
5859
+ " match_field="
59-
+ matchField
60+
+ matchField.string()
6061
+ " load_fields="
6162
+ loadFields
6263
+ " inputChannel="
@@ -76,7 +77,7 @@ public Operator get(DriverContext driverContext) {
7677
inputDataType,
7778
lookupIndexPattern,
7879
lookupIndex,
79-
matchField,
80+
matchField.string(),
8081
loadFields,
8182
source
8283
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,10 +766,10 @@ private PhysicalOperation planLookupJoin(LookupJoinExec join, LocalExecutionPlan
766766
);
767767
}
768768

769-
private record MatchConfig(String fieldName, int channel, DataType type) {
769+
private record MatchConfig(FieldAttribute.FieldName fieldName, int channel, DataType type) {
770770
private MatchConfig(FieldAttribute match, Layout.ChannelAndType input) {
771771
// Note, this handles TEXT fields with KEYWORD subfields
772-
this(match.exactAttribute().name(), input.channel(), input.type());
772+
this(match.exactAttribute().fieldName(), input.channel(), input.type());
773773
}
774774
}
775775

0 commit comments

Comments
 (0)