| 
14 | 14 | import org.elasticsearch.xpack.esql.core.expression.Expression;  | 
15 | 15 | import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;  | 
16 | 16 | 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;  | 
19 | 18 | import org.elasticsearch.xpack.esql.expression.function.scalar.math.RoundTo;  | 
20 | 19 | import org.elasticsearch.xpack.esql.optimizer.LocalLogicalPlanOptimizerTests;  | 
21 | 20 | import org.elasticsearch.xpack.esql.plan.logical.Aggregate;  | 
@@ -243,18 +242,14 @@ private void verifySubstitution(Alias a, int roundToPointsSize) {  | 
243 | 242 |             fa = as(roundTo.field(), FieldAttribute.class);  | 
244 | 243 |             assertEquals(roundToPointsSize, roundTo.points().size());  | 
245 | 244 |         } 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);  | 
250 | 247 |             } else {  | 
251 | 248 |                 fail(e.getClass() + " is not supported");  | 
252 | 249 |             }  | 
253 | 250 |         } 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);  | 
258 | 253 |             } else {  | 
259 | 254 |                 fail(e.getClass() + " is not supported");  | 
260 | 255 |             }  | 
 | 
0 commit comments