Skip to content

Commit def5d8d

Browse files
refactor tests
1 parent 5ba54a5 commit def5d8d

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/rules/logical/local/LocalSubstituteSurrogateExpressionTests.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
import org.elasticsearch.xpack.esql.core.expression.Expression;
1515
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
1616
import org.elasticsearch.xpack.esql.core.expression.ReferenceAttribute;
17-
import org.elasticsearch.xpack.esql.expression.function.grouping.Bucket;
18-
import org.elasticsearch.xpack.esql.expression.function.scalar.date.DateTrunc;
17+
import org.elasticsearch.xpack.esql.expression.LocalSurrogateExpression;
1918
import org.elasticsearch.xpack.esql.expression.function.scalar.math.RoundTo;
2019
import org.elasticsearch.xpack.esql.optimizer.LocalLogicalPlanOptimizerTests;
2120
import org.elasticsearch.xpack.esql.plan.logical.Aggregate;
@@ -243,18 +242,14 @@ private void verifySubstitution(Alias a, int roundToPointsSize) {
243242
fa = as(roundTo.field(), FieldAttribute.class);
244243
assertEquals(roundToPointsSize, roundTo.points().size());
245244
} else if (roundToPointsSize == 0) {
246-
if (e instanceof DateTrunc dateTrunc) {
247-
fa = as(dateTrunc.field(), FieldAttribute.class);
248-
} else if (e instanceof Bucket bucket) {
249-
fa = as(bucket.field(), FieldAttribute.class);
245+
if (e instanceof LocalSurrogateExpression lse) {
246+
fa = as(lse.field(), FieldAttribute.class);
250247
} else {
251248
fail(e.getClass() + " is not supported");
252249
}
253250
} else {
254-
if (e instanceof DateTrunc dateTrunc) {
255-
assertTrue(dateTrunc.field() instanceof ReferenceAttribute);
256-
} else if (e instanceof Bucket bucket) {
257-
assertTrue(bucket.field() instanceof ReferenceAttribute);
251+
if (e instanceof LocalSurrogateExpression lse) {
252+
assertTrue(lse.field() instanceof ReferenceAttribute);
258253
} else {
259254
fail(e.getClass() + " is not supported");
260255
}

0 commit comments

Comments
 (0)