|
37 | 37 | import org.elasticsearch.xpack.esql.core.type.DataType;
|
38 | 38 | import org.elasticsearch.xpack.esql.parser.ParsingException;
|
39 | 39 | import org.elasticsearch.xpack.esql.plugin.EsqlPlugin;
|
| 40 | +import org.elasticsearch.xpack.esql.plugin.QueryPragmas; |
40 | 41 | import org.junit.Before;
|
41 | 42 |
|
42 | 43 | import java.io.IOException;
|
@@ -1673,17 +1674,32 @@ public void testScriptField() throws Exception {
|
1673 | 1674 | String sourceMode = randomBoolean() ? "stored" : "synthetic";
|
1674 | 1675 | Settings.Builder settings = indexSettings(1, 0).put(indexSettings()).put("index.mapping.source.mode", sourceMode);
|
1675 | 1676 | client().admin().indices().prepareCreate("test-script").setMapping(mapping).setSettings(settings).get();
|
1676 |
| - for (int i = 0; i < 10; i++) { |
| 1677 | + int numDocs = 256; |
| 1678 | + for (int i = 0; i < numDocs; i++) { |
1677 | 1679 | index("test-script", Integer.toString(i), Map.of("k1", i, "k2", "b-" + i, "meter", 10000 * i));
|
1678 | 1680 | }
|
1679 | 1681 | refresh("test-script");
|
1680 |
| - try (EsqlQueryResponse resp = run("FROM test-script | SORT k1 | LIMIT 10")) { |
| 1682 | + |
| 1683 | + var pragmas = randomPragmas(); |
| 1684 | + if (canUseQueryPragmas()) { |
| 1685 | + Settings.Builder pragmaSettings = Settings.builder().put(pragmas.getSettings()); |
| 1686 | + pragmaSettings.put("task_concurrency", 10); |
| 1687 | + pragmaSettings.put("data_partitioning", "doc"); |
| 1688 | + pragmas = new QueryPragmas(pragmaSettings.build()); |
| 1689 | + } |
| 1690 | + try (EsqlQueryResponse resp = run("FROM test-script | SORT k1 | LIMIT " + numDocs, pragmas)) { |
1681 | 1691 | List<Object> k1Column = Iterators.toList(resp.column(0));
|
1682 |
| - assertThat(k1Column, contains(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L)); |
| 1692 | + assertThat(k1Column, equalTo(LongStream.range(0L, numDocs).boxed().toList())); |
1683 | 1693 | List<Object> k2Column = Iterators.toList(resp.column(1));
|
1684 |
| - assertThat(k2Column, contains(null, null, null, null, null, null, null, null, null, null)); |
| 1694 | + assertThat(k2Column, equalTo(Collections.nCopies(numDocs, null))); |
1685 | 1695 | List<Object> meterColumn = Iterators.toList(resp.column(2));
|
1686 |
| - assertThat(meterColumn, contains(0.0, 10000.0, 20000.0, 30000.0, 40000.0, 50000.0, 60000.0, 70000.0, 80000.0, 90000.0)); |
| 1696 | + var expectedMeterColumn = new ArrayList<>(numDocs); |
| 1697 | + double val = 0.0; |
| 1698 | + for (int i = 0; i < numDocs; i++) { |
| 1699 | + expectedMeterColumn.add(val); |
| 1700 | + val += 10000.0; |
| 1701 | + } |
| 1702 | + assertThat(meterColumn, equalTo(expectedMeterColumn)); |
1687 | 1703 | }
|
1688 | 1704 | }
|
1689 | 1705 |
|
|
0 commit comments