|
12 | 12 | import org.elasticsearch.xpack.sql.analysis.index.EsIndex; |
13 | 13 | import org.elasticsearch.xpack.sql.analysis.index.IndexResolution; |
14 | 14 | import org.elasticsearch.xpack.sql.expression.function.FunctionRegistry; |
| 15 | +import org.elasticsearch.xpack.sql.expression.function.aggregate.AggregateFunctionAttribute; |
15 | 16 | import org.elasticsearch.xpack.sql.optimizer.Optimizer; |
16 | 17 | import org.elasticsearch.xpack.sql.parser.SqlParser; |
17 | 18 | import org.elasticsearch.xpack.sql.plan.physical.EsQueryExec; |
@@ -316,4 +317,24 @@ public void testConcatIsNotFoldedForNull() { |
316 | 317 | assertEquals(1, ee.output().size()); |
317 | 318 | assertThat(ee.output().get(0).toString(), startsWith("keyword{f}#")); |
318 | 319 | } |
| 320 | + |
| 321 | + public void testFoldingOfPercentileSecondArgument() { |
| 322 | + PhysicalPlan p = plan("SELECT PERCENTILE(int, 1 + 2) FROM test"); |
| 323 | + assertEquals(EsQueryExec.class, p.getClass()); |
| 324 | + EsQueryExec ee = (EsQueryExec) p; |
| 325 | + assertEquals(1, ee.output().size()); |
| 326 | + assertEquals(AggregateFunctionAttribute.class, ee.output().get(0).getClass()); |
| 327 | + AggregateFunctionAttribute afa = (AggregateFunctionAttribute) ee.output().get(0); |
| 328 | + assertThat(afa.propertyPath(), endsWith("[3.0]")); |
| 329 | + } |
| 330 | + |
| 331 | + public void testFoldingOfPercentileRankSecondArgument() { |
| 332 | + PhysicalPlan p = plan("SELECT PERCENTILE_RANK(int, 1 + 2) FROM test"); |
| 333 | + assertEquals(EsQueryExec.class, p.getClass()); |
| 334 | + EsQueryExec ee = (EsQueryExec) p; |
| 335 | + assertEquals(1, ee.output().size()); |
| 336 | + assertEquals(AggregateFunctionAttribute.class, ee.output().get(0).getClass()); |
| 337 | + AggregateFunctionAttribute afa = (AggregateFunctionAttribute) ee.output().get(0); |
| 338 | + assertThat(afa.propertyPath(), endsWith("[3.0]")); |
| 339 | + } |
319 | 340 | } |
0 commit comments