|
15 | 15 | import org.elasticsearch.core.PathUtils; |
16 | 16 | import org.elasticsearch.core.SuppressForbidden; |
17 | 17 | import org.elasticsearch.dissect.DissectParser; |
| 18 | +import org.elasticsearch.index.IndexMode; |
18 | 19 | import org.elasticsearch.test.ESTestCase; |
19 | 20 | import org.elasticsearch.xpack.core.enrich.EnrichPolicy; |
20 | 21 | import org.elasticsearch.xpack.esql.core.capabilities.UnresolvedException; |
|
42 | 43 | import org.elasticsearch.xpack.esql.expression.predicate.fulltext.FullTextPredicate; |
43 | 44 | import org.elasticsearch.xpack.esql.index.EsIndex; |
44 | 45 | import org.elasticsearch.xpack.esql.plan.logical.Dissect; |
| 46 | +import org.elasticsearch.xpack.esql.plan.logical.EsRelation; |
| 47 | +import org.elasticsearch.xpack.esql.plan.logical.Fork; |
45 | 48 | import org.elasticsearch.xpack.esql.plan.logical.Grok; |
46 | 49 | import org.elasticsearch.xpack.esql.plan.logical.LogicalPlan; |
| 50 | +import org.elasticsearch.xpack.esql.plan.logical.Merge; |
47 | 51 | import org.elasticsearch.xpack.esql.plan.logical.join.JoinConfig; |
48 | 52 | import org.elasticsearch.xpack.esql.plan.logical.join.JoinType; |
49 | 53 | import org.elasticsearch.xpack.esql.plan.logical.join.JoinTypes; |
50 | 54 | import org.elasticsearch.xpack.esql.plan.physical.EsQueryExec; |
51 | 55 | import org.elasticsearch.xpack.esql.plan.physical.EsStatsQueryExec.Stat; |
52 | 56 | import org.elasticsearch.xpack.esql.plan.physical.EsStatsQueryExec.StatsType; |
| 57 | +import org.elasticsearch.xpack.esql.plan.physical.MergeExec; |
53 | 58 | import org.elasticsearch.xpack.esql.plan.physical.OutputExec; |
54 | 59 | import org.elasticsearch.xpack.esql.plan.physical.PhysicalPlan; |
55 | 60 | import org.elasticsearch.xpack.esql.session.Configuration; |
|
89 | 94 | import static org.elasticsearch.xpack.esql.ConfigurationTestUtils.randomConfiguration; |
90 | 95 | import static org.elasticsearch.xpack.esql.core.type.DataType.GEO_POINT; |
91 | 96 | import static org.elasticsearch.xpack.esql.index.EsIndexSerializationTests.randomEsIndex; |
| 97 | +import static org.elasticsearch.xpack.esql.index.EsIndexSerializationTests.randomIndexNameWithModes; |
| 98 | +import static org.elasticsearch.xpack.esql.plan.AbstractNodeSerializationTests.randomFieldAttributes; |
92 | 99 | import static org.mockito.Mockito.mock; |
93 | 100 |
|
94 | 101 | /** |
@@ -441,6 +448,9 @@ public void accept(Page page) { |
441 | 448 | return randomInt(); |
442 | 449 | } else if (argClass == JoinType.class) { |
443 | 450 | return JoinTypes.LEFT; |
| 451 | + } else if (List.of(Fork.class, Merge.class, MergeExec.class).contains(toBuildClass) && argType == LogicalPlan.class) { |
| 452 | + // limit recursion of plans, in order to prevent stackoverflow errors |
| 453 | + return randomEsRelation(); |
444 | 454 | } |
445 | 455 |
|
446 | 456 | if (Expression.class == argClass) { |
@@ -709,6 +719,16 @@ static EsQueryExec.GeoDistanceSort randomGeoDistanceSort() { |
709 | 719 | ); |
710 | 720 | } |
711 | 721 |
|
| 722 | + static EsRelation randomEsRelation() { |
| 723 | + return new EsRelation( |
| 724 | + SourceTests.randomSource(), |
| 725 | + randomIdentifier(), |
| 726 | + randomFrom(IndexMode.values()), |
| 727 | + randomIndexNameWithModes(), |
| 728 | + randomFieldAttributes(0, 10, false) |
| 729 | + ); |
| 730 | + } |
| 731 | + |
712 | 732 | static FieldAttribute field(String name, DataType type) { |
713 | 733 | return new FieldAttribute(Source.EMPTY, name, new EsField(name, type, Collections.emptyMap(), false)); |
714 | 734 | } |
|
0 commit comments