|
32 | 32 |
|
33 | 33 | import static java.util.Collections.nCopies; |
34 | 34 | import static java.util.stream.Collectors.toList; |
| 35 | +import static org.hamcrest.Matchers.containsString; |
35 | 36 | import static org.hamcrest.Matchers.hasEntry; |
36 | 37 | import static org.hamcrest.Matchers.hasSize; |
37 | 38 | import static org.hamcrest.Matchers.instanceOf; |
@@ -391,6 +392,34 @@ public void testQuotedIndexNameWithQuotedCluster() { |
391 | 392 | assertEquals("elastic", relation.table().cluster()); |
392 | 393 | } |
393 | 394 |
|
| 395 | + public void testIndexNameDataSelector() { |
| 396 | + Project plan = project(parseStatement("SELECT * FROM foo::data")); |
| 397 | + |
| 398 | + assertThat(plan.child(), instanceOf(UnresolvedRelation.class)); |
| 399 | + UnresolvedRelation relation = (UnresolvedRelation) plan.child(); |
| 400 | + assertEquals("foo", relation.table().index()); |
| 401 | + assertNull(relation.table().cluster()); |
| 402 | + assertEquals("data", relation.table().selector()); |
| 403 | + } |
| 404 | + |
| 405 | + public void testIndexNameFailuresSelector() { |
| 406 | + Project plan = project(parseStatement("SELECT * FROM foo::failures")); |
| 407 | + |
| 408 | + assertThat(plan.child(), instanceOf(UnresolvedRelation.class)); |
| 409 | + UnresolvedRelation relation = (UnresolvedRelation) plan.child(); |
| 410 | + assertEquals("foo", relation.table().index()); |
| 411 | + assertNull(relation.table().cluster()); |
| 412 | + assertEquals("failures", relation.table().selector()); |
| 413 | + } |
| 414 | + |
| 415 | + public void testIndexNameClusterSeletorCombined() { |
| 416 | + ParsingException e = expectThrows(ParsingException.class, () -> parseStatement("SELECT * FROM cluster:foo::failures")); |
| 417 | + assertThat( |
| 418 | + e.getMessage(), |
| 419 | + containsString("mismatched input '::' expecting {") |
| 420 | + ); |
| 421 | + } |
| 422 | + |
394 | 423 | private LogicalPlan parseStatement(String sql) { |
395 | 424 | return new SqlParser().createStatement(sql); |
396 | 425 | } |
|
0 commit comments