use of io.crate.sql.tree.IntegerLiteral in project crate by crate.
the class TestStatementBuilder method testSubscriptExpression.
@Test
public void testSubscriptExpression() {
Expression expression = SqlParser.createExpression("a['sub']");
assertThat(expression, instanceOf(SubscriptExpression.class));
SubscriptExpression subscript = (SubscriptExpression) expression;
assertThat(subscript.index(), instanceOf(StringLiteral.class));
assertThat(((StringLiteral) subscript.index()).getValue(), is("sub"));
assertThat(subscript.base(), instanceOf(QualifiedNameReference.class));
expression = SqlParser.createExpression("[1,2,3][1]");
assertThat(expression, instanceOf(SubscriptExpression.class));
subscript = (SubscriptExpression) expression;
assertThat(subscript.index(), instanceOf(IntegerLiteral.class));
assertThat(((IntegerLiteral) subscript.index()).getValue(), is(1));
assertThat(subscript.base(), instanceOf(ArrayLiteral.class));
}
Aggregations