Skip to content

Commit 9d3200a

Browse files
committed
Add tests for COMPLETION logical plan optimization.
1 parent a93f840 commit 9d3200a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
import org.elasticsearch.xpack.esql.optimizer.rules.logical.OptimizerRules;
101101
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PruneRedundantOrderBy;
102102
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownAndCombineLimits;
103+
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownCompletion;
103104
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEnrich;
104105
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownEval;
105106
import org.elasticsearch.xpack.esql.optimizer.rules.logical.PushDownRegexExtract;
@@ -123,6 +124,7 @@
123124
import org.elasticsearch.xpack.esql.plan.logical.TimeSeriesAggregate;
124125
import org.elasticsearch.xpack.esql.plan.logical.TopN;
125126
import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan;
127+
import org.elasticsearch.xpack.esql.plan.logical.inference.Completion;
126128
import org.elasticsearch.xpack.esql.plan.logical.join.InlineJoin;
127129
import org.elasticsearch.xpack.esql.plan.logical.join.Join;
128130
import org.elasticsearch.xpack.esql.plan.logical.join.JoinConfig;
@@ -162,6 +164,7 @@
162164
import static org.elasticsearch.xpack.esql.EsqlTestUtils.getFieldAttribute;
163165
import static org.elasticsearch.xpack.esql.EsqlTestUtils.loadMapping;
164166
import static org.elasticsearch.xpack.esql.EsqlTestUtils.localSource;
167+
import static org.elasticsearch.xpack.esql.EsqlTestUtils.randomLiteral;
165168
import static org.elasticsearch.xpack.esql.EsqlTestUtils.referenceAttribute;
166169
import static org.elasticsearch.xpack.esql.EsqlTestUtils.singleValue;
167170
import static org.elasticsearch.xpack.esql.EsqlTestUtils.unboundLogicalOptimizerContext;
@@ -176,6 +179,7 @@
176179
import static org.elasticsearch.xpack.esql.core.type.DataType.INTEGER;
177180
import static org.elasticsearch.xpack.esql.core.type.DataType.KEYWORD;
178181
import static org.elasticsearch.xpack.esql.core.type.DataType.LONG;
182+
import static org.elasticsearch.xpack.esql.core.type.DataType.TEXT;
179183
import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.EQ;
180184
import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.GT;
181185
import static org.elasticsearch.xpack.esql.expression.predicate.operator.comparison.EsqlBinaryComparison.BinaryComparisonOperation.GTE;
@@ -5556,7 +5560,18 @@ record PushdownShadowingGeneratingPlanTestCase(
55565560
)
55575561
),
55585562
new PushDownEnrich()
5559-
) };
5563+
),
5564+
// | COMPLETION CONCAT(some text, x) WITH inferenceID AS y
5565+
new PushdownShadowingGeneratingPlanTestCase(
5566+
(plan, attr) -> new Completion(
5567+
EMPTY,
5568+
plan,
5569+
randomLiteral(TEXT),
5570+
new Concat(EMPTY, randomLiteral(TEXT), List.of(attr)),
5571+
new ReferenceAttribute(EMPTY, "y", KEYWORD)
5572+
),
5573+
new PushDownCompletion()
5574+
)};
55605575

55615576
/**
55625577
* Consider

0 commit comments

Comments
 (0)