Skip to content

Commit 3e2c976

Browse files
committed
Update and add some test cases
1 parent 9a7e4fa commit 3e2c976

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

x-pack/plugin/eql/src/test/java/org/elasticsearch/xpack/eql/optimizer/OptimizerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ private static Attribute tiebreaker() {
753753
}
754754

755755
private static LogicalPlan rel() {
756-
return new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, "catalog", "index"), "", false);
756+
return new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, "catalog", "index", "data"), "", false);
757757
}
758758

759759
private static KeyedFilter keyedFilter(LogicalPlan child) {

x-pack/plugin/ql/src/test/java/org/elasticsearch/xpack/ql/analyzer/PreAnalyzerTests.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,40 @@ public class PreAnalyzerTests extends ESTestCase {
2525
private PreAnalyzer preAnalyzer = new PreAnalyzer();
2626

2727
public void testBasicIndex() {
28-
LogicalPlan plan = new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, null, "index"), null, false);
28+
LogicalPlan plan = new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, null, "index", null), null, false);
2929
PreAnalysis result = preAnalyzer.preAnalyze(plan);
3030
assertThat(plan.preAnalyzed(), is(true));
3131
assertThat(result.indices, hasSize(1));
3232
assertThat(result.indices.get(0).id().cluster(), nullValue());
3333
assertThat(result.indices.get(0).id().index(), is("index"));
34+
assertThat(result.indices.get(0).id().selector(), nullValue());
3435
}
3536

3637
public void testBasicIndexWithCatalog() {
37-
LogicalPlan plan = new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, "elastic", "index"), null, false);
38+
LogicalPlan plan = new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, "elastic", "index", null), null, false);
3839
PreAnalysis result = preAnalyzer.preAnalyze(plan);
3940
assertThat(plan.preAnalyzed(), is(true));
4041
assertThat(result.indices, hasSize(1));
4142
assertThat(result.indices.get(0).id().cluster(), is("elastic"));
4243
assertThat(result.indices.get(0).id().index(), is("index"));
44+
assertThat(result.indices.get(0).id().selector(), nullValue());
45+
}
46+
47+
public void testBasicIndexWithSelector() {
48+
LogicalPlan plan = new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, null, "index", "failures"), null, false);
49+
PreAnalysis result = preAnalyzer.preAnalyze(plan);
50+
assertThat(plan.preAnalyzed(), is(true));
51+
assertThat(result.indices, hasSize(1));
52+
assertThat(result.indices.get(0).id().cluster(), nullValue());
53+
assertThat(result.indices.get(0).id().index(), is("index"));
54+
assertThat(result.indices.get(0).id().selector(), is("failures"));
4355
}
4456

4557
public void testComplicatedQuery() {
4658
LogicalPlan plan = new Limit(
4759
EMPTY,
4860
new Literal(EMPTY, 10, INTEGER),
49-
new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, null, "aaa"), null, false)
61+
new UnresolvedRelation(EMPTY, new TableIdentifier(EMPTY, null, "aaa", null), null, false)
5062
);
5163
PreAnalysis result = preAnalyzer.preAnalyze(plan);
5264
assertThat(plan.preAnalyzed(), is(true));

x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plan/logical/UnresolvedRelationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@
2121
public class UnresolvedRelationTests extends ESTestCase {
2222
public void testEqualsAndHashCode() {
2323
Source source = new Source(between(1, 1000), between(1, 1000), randomAlphaOfLength(16));
24-
TableIdentifier table = new TableIdentifier(source, randomAlphaOfLength(5), randomAlphaOfLength(5));
24+
TableIdentifier table = new TableIdentifier(source, randomAlphaOfLength(5), randomAlphaOfLength(5), randomAlphaOfLength(5));
2525
String alias = randomBoolean() ? null : randomAlphaOfLength(5);
2626
String unresolvedMessage = randomAlphaOfLength(5);
2727
UnresolvedRelation relation = new UnresolvedRelation(source, table, alias, randomBoolean(), unresolvedMessage);
2828
List<Function<UnresolvedRelation, UnresolvedRelation>> mutators = new ArrayList<>();
2929
mutators.add(
3030
r -> new UnresolvedRelation(
3131
r.source(),
32-
new TableIdentifier(r.source(), r.table().cluster(), r.table().index() + "m"),
32+
new TableIdentifier(r.source(), r.table().cluster(), r.table().index() + "m", r.table().selector()),
3333
r.alias(),
3434
r.frozen(),
3535
r.unresolvedMessage()

0 commit comments

Comments
 (0)