|
61 | 61 | import org.elasticsearch.xpack.esql.plan.logical.Project;
|
62 | 62 | import org.elasticsearch.xpack.esql.plan.logical.Row;
|
63 | 63 | import org.elasticsearch.xpack.esql.plan.logical.UnaryPlan;
|
64 |
| -import org.elasticsearch.xpack.esql.plan.logical.join.Join; |
65 |
| -import org.elasticsearch.xpack.esql.plan.logical.join.JoinConfig; |
66 |
| -import org.elasticsearch.xpack.esql.plan.logical.join.JoinTypes; |
67 | 64 | import org.elasticsearch.xpack.esql.plan.logical.local.EmptyLocalSupplier;
|
68 | 65 | import org.elasticsearch.xpack.esql.plan.logical.local.EsqlProject;
|
69 | 66 | import org.elasticsearch.xpack.esql.plan.logical.local.LocalRelation;
|
|
99 | 96 | import static org.elasticsearch.xpack.esql.EsqlTestUtils.withDefaultLimitWarning;
|
100 | 97 | import static org.elasticsearch.xpack.esql.core.tree.Source.EMPTY;
|
101 | 98 | import static org.elasticsearch.xpack.esql.core.type.DataType.INTEGER;
|
102 |
| -import static org.elasticsearch.xpack.esql.core.type.DataType.KEYWORD; |
103 | 99 | import static org.elasticsearch.xpack.esql.optimizer.rules.logical.OptimizerRules.TransformDirection.DOWN;
|
104 | 100 | import static org.elasticsearch.xpack.esql.optimizer.rules.logical.OptimizerRules.TransformDirection.UP;
|
105 | 101 | import static org.hamcrest.Matchers.contains;
|
@@ -1023,58 +1019,6 @@ public List<Attribute> output() {
|
1023 | 1019 | assertThat(e.getMessage(), containsString("Output has changed from"));
|
1024 | 1020 | }
|
1025 | 1021 |
|
1026 |
| - /** |
1027 |
| - * Input: |
1028 |
| - * Project[[key{f}#2, int{f}#3, field1{f}#7, field2{f}#8]] |
1029 |
| - * \_Join[LEFT,[key{f}#2],[key{f}#6],null] |
1030 |
| - * |_EsRelation[JLfQlKmn][key{f}#2, int{f}#3, field1{f}#4, field2{f}#5] |
1031 |
| - * \_EsRelation[HQtEBOWq][LOOKUP][key{f}#6, field1{f}#7, field2{f}#8] |
1032 |
| - * |
1033 |
| - * Output: |
1034 |
| - * Project[[key{r}#2, int{f}#3, field1{r}#7, field1{r}#7 AS field2#8]] |
1035 |
| - * \_Eval[[null[KEYWORD] AS key#2, null[INTEGER] AS field1#7]] |
1036 |
| - * \_EsRelation[JLfQlKmn][key{f}#2, int{f}#3, field1{f}#4, field2{f}#5] |
1037 |
| - */ |
1038 |
| - public void testPruneLeftJoinOnNullMatchingFieldAndShadowingAttributes() { |
1039 |
| - var keyLeft = getFieldAttribute("key", KEYWORD); |
1040 |
| - var intFieldLeft = getFieldAttribute("int"); |
1041 |
| - var fieldLeft1 = getFieldAttribute("field1"); |
1042 |
| - var fieldLeft2 = getFieldAttribute("field2"); |
1043 |
| - var leftRelation = EsqlTestUtils.relation(IndexMode.STANDARD) |
1044 |
| - .withAttributes(List.of(keyLeft, intFieldLeft, fieldLeft1, fieldLeft2)); |
1045 |
| - |
1046 |
| - var keyRight = getFieldAttribute("key", KEYWORD); |
1047 |
| - var fieldRight1 = getFieldAttribute("field1"); |
1048 |
| - var fieldRight2 = getFieldAttribute("field2"); |
1049 |
| - var rightRelation = EsqlTestUtils.relation(IndexMode.LOOKUP).withAttributes(List.of(keyRight, fieldRight1, fieldRight2)); |
1050 |
| - |
1051 |
| - JoinConfig joinConfig = new JoinConfig(JoinTypes.LEFT, List.of(keyLeft), List.of(keyRight), null); |
1052 |
| - var join = new Join(EMPTY, leftRelation, rightRelation, joinConfig); |
1053 |
| - var project = new Project(EMPTY, join, List.of(keyLeft, intFieldLeft, fieldRight1, fieldRight2)); |
1054 |
| - |
1055 |
| - var testStats = statsForMissingField("key"); |
1056 |
| - var localPlan = localPlan(project, testStats); |
1057 |
| - |
1058 |
| - var projectOut = as(localPlan, Project.class); |
1059 |
| - var projectionsOut = projectOut.projections(); |
1060 |
| - assertThat(Expressions.names(projectionsOut), contains("key", "int", "field1", "field2")); |
1061 |
| - assertThat(projectionsOut.get(0).id(), is(keyLeft.id())); |
1062 |
| - assertThat(projectionsOut.get(1).id(), is(intFieldLeft.id())); |
1063 |
| - assertThat(projectionsOut.get(2).id(), is(fieldRight1.id())); // id must remain from the RHS. |
1064 |
| - var aliasField2 = as(projectionsOut.get(3), Alias.class); // the projection must contain an alias ... |
1065 |
| - assertThat(aliasField2.id(), is(fieldRight2.id())); // ... with the same id as the original field. |
1066 |
| - |
1067 |
| - var eval = as(projectOut.child(), Eval.class); |
1068 |
| - assertThat(Expressions.names(eval.fields()), contains("key", "field1")); |
1069 |
| - var keyEval = as(Alias.unwrap(eval.fields().get(0)), Literal.class); |
1070 |
| - assertThat(keyEval.value(), is(nullValue())); |
1071 |
| - assertThat(keyEval.dataType(), is(KEYWORD)); |
1072 |
| - var field1Eval = as(Alias.unwrap(eval.fields().get(1)), Literal.class); |
1073 |
| - assertThat(field1Eval.value(), is(nullValue())); |
1074 |
| - assertThat(field1Eval.dataType(), is(INTEGER)); |
1075 |
| - var source = as(eval.child(), EsRelation.class); |
1076 |
| - } |
1077 |
| - |
1078 | 1022 | private IsNotNull isNotNull(Expression field) {
|
1079 | 1023 | return new IsNotNull(EMPTY, field);
|
1080 | 1024 | }
|
@@ -1134,6 +1078,6 @@ protected List<String> filteredWarnings() {
|
1134 | 1078 | }
|
1135 | 1079 |
|
1136 | 1080 | public static EsRelation relation() {
|
1137 |
| - return EsqlTestUtils.relation(randomFrom(IndexMode.values())); |
| 1081 | + return new EsRelation(EMPTY, new EsIndex(randomAlphaOfLength(8), emptyMap()), randomFrom(IndexMode.values())); |
1138 | 1082 | }
|
1139 | 1083 | }
|
0 commit comments