use of io.crate.sql.tree.ArrayComparisonExpression in project crate by crate.
the class TestStatementBuilder method testArrayComparison.
@Test
public void testArrayComparison() {
Expression anyExpression = SqlParser.createExpression("1 = ANY (arrayColumnRef)");
assertThat(anyExpression, instanceOf(ArrayComparisonExpression.class));
ArrayComparisonExpression arrayComparisonExpression = (ArrayComparisonExpression) anyExpression;
assertThat(arrayComparisonExpression.quantifier(), is(ArrayComparisonExpression.Quantifier.ANY));
assertThat(arrayComparisonExpression.getLeft(), instanceOf(IntegerLiteral.class));
assertThat(arrayComparisonExpression.getRight(), instanceOf(QualifiedNameReference.class));
Expression someExpression = SqlParser.createExpression("1 = SOME (arrayColumnRef)");
assertThat(someExpression, instanceOf(ArrayComparisonExpression.class));
ArrayComparisonExpression someArrayComparison = (ArrayComparisonExpression) someExpression;
assertThat(someArrayComparison.quantifier(), is(ArrayComparisonExpression.Quantifier.ANY));
assertThat(someArrayComparison.getLeft(), instanceOf(IntegerLiteral.class));
assertThat(someArrayComparison.getRight(), instanceOf(QualifiedNameReference.class));
Expression allExpression = SqlParser.createExpression("'StringValue' = ALL (arrayColumnRef)");
assertThat(allExpression, instanceOf(ArrayComparisonExpression.class));
ArrayComparisonExpression allArrayComparison = (ArrayComparisonExpression) allExpression;
assertThat(allArrayComparison.quantifier(), is(ArrayComparisonExpression.Quantifier.ALL));
assertThat(allArrayComparison.getLeft(), instanceOf(StringLiteral.class));
assertThat(allArrayComparison.getRight(), instanceOf(QualifiedNameReference.class));
}
use of io.crate.sql.tree.ArrayComparisonExpression in project crate by crate.
the class TestStatementBuilder method testArrayComparisonSubSelect.
@Test
public void testArrayComparisonSubSelect() {
Expression anyExpression = SqlParser.createExpression("1 = ANY ((SELECT 5))");
assertThat(anyExpression, instanceOf(ArrayComparisonExpression.class));
ArrayComparisonExpression arrayComparisonExpression = (ArrayComparisonExpression) anyExpression;
assertThat(arrayComparisonExpression.quantifier(), is(ArrayComparisonExpression.Quantifier.ANY));
assertThat(arrayComparisonExpression.getLeft(), instanceOf(IntegerLiteral.class));
assertThat(arrayComparisonExpression.getRight(), instanceOf(SubqueryExpression.class));
// It's possible to omit the parenthesis
anyExpression = SqlParser.createExpression("1 = ANY (SELECT 5)");
assertThat(anyExpression, instanceOf(ArrayComparisonExpression.class));
arrayComparisonExpression = (ArrayComparisonExpression) anyExpression;
assertThat(arrayComparisonExpression.quantifier(), is(ArrayComparisonExpression.Quantifier.ANY));
assertThat(arrayComparisonExpression.getLeft(), instanceOf(IntegerLiteral.class));
assertThat(arrayComparisonExpression.getRight(), instanceOf(SubqueryExpression.class));
}
Aggregations