Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1942,13 +1942,7 @@ private static LogicalPlan addGeneratedFieldsToEsRelations(LogicalPlan plan, Lis
}

if (missing.isEmpty() == false) {
return new EsRelation(
esr.source(),
esr.indexPattern(),
esr.indexMode(),
esr.indexNameWithModes(),
CollectionUtils.combine(esr.output(), missing)
);
return esr.withAttributes(CollectionUtils.combine(esr.output(), missing));
}
return esr;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private static LogicalPlan pruneColumnsInEsRelation(EsRelation esr, AttributeSet
// it works differently as we extract all fields (other than the join key) that the EsRelation has.
var remaining = pruneUnusedAndAddReferences(esr.output(), used);
if (remaining != null) {
p = new EsRelation(esr.source(), esr.indexPattern(), esr.indexMode(), esr.indexNameWithModes(), remaining);
p = esr.withAttributes(remaining);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public PruneUnusedIndexMode() {
protected LogicalPlan rule(EsRelation r) {
if (r.indexMode() == IndexMode.TIME_SERIES) {
if (Expressions.anyMatch(r.output(), a -> MetadataAttribute.TSID_FIELD.equals(((Attribute) a).name())) == false) {
return new EsRelation(r.source(), r.indexPattern(), IndexMode.STANDARD, r.indexNameWithModes(), r.output());
return r.withIndexMode(IndexMode.STANDARD);
}
}
return r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,9 @@ protected LogicalPlan rule(TimeSeriesAggregate aggregate, LogicalOptimizerContex
LogicalPlan newChild = aggregate.child().transformUp(EsRelation.class, r -> {
IndexMode indexMode = requiredTimeSeriesSource.get() ? r.indexMode() : IndexMode.STANDARD;
if (r.output().contains(tsid.get()) == false) {
return new EsRelation(
r.source(),
r.indexPattern(),
indexMode,
r.indexNameWithModes(),
CollectionUtils.combine(r.output(), tsid.get())
);
return r.withIndexMode(indexMode).withAttributes(CollectionUtils.combine(r.output(), tsid.get()));
} else {
return new EsRelation(r.source(), r.indexPattern(), indexMode, r.indexNameWithModes(), r.output());
return r.withIndexMode(indexMode);
}
});
final var firstPhase = new TimeSeriesAggregate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,8 @@ public String nodeString() {
public EsRelation withAttributes(List<Attribute> newAttributes) {
return new EsRelation(source(), indexPattern, indexMode, indexNameWithModes, newAttributes);
}

public EsRelation withIndexMode(IndexMode indexMode) {
return new EsRelation(source(), indexPattern, indexMode, indexNameWithModes, attrs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static Optional<ReductionPlan> planReduceDriverTopN(
return r;
}
List<Attribute> attributes = CollectionUtils.prependToCopy(doc, r.output());
return new EsRelation(r.source(), r.indexPattern(), r.indexMode(), r.indexNameWithModes(), attributes);
return r.withAttributes(attributes);
});
if (withAddedDocToRelation.output().stream().noneMatch(EsQueryExec::isDocAttribute)) {
// Defensive check: if any intermediate projects (or possibly another operator) removed the doc field, just abort this
Expand Down