use of io.crate.testing.SqlExpressions in project crate by crate.
the class UnnestFunctionTest method prepareFunctions.
@Before
public void prepareFunctions() throws Exception {
sqlExpressions = new SqlExpressions(ImmutableMap.of(QualifiedName.of("t"), mock(DocTableRelation.class)));
functions = sqlExpressions.getInstance(Functions.class);
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class LuceneQueryBuilderTest method testEqOnArrayWithTooManyClauses.
@Test
public void testEqOnArrayWithTooManyClauses() throws Exception {
// should trigger the TooManyClauses exception
Object[] values = new Object[2000];
Arrays.fill(values, 10L);
SqlExpressions sqlExpressions = new SqlExpressions(sources, new Object[] { values });
Query query = convert(new WhereClause(expressions.normalize(sqlExpressions.asSymbol("y_array = ?"))));
assertThat(query, instanceOf(BooleanQuery.class));
BooleanQuery booleanQuery = (BooleanQuery) query;
assertThat(booleanQuery.clauses().get(0).getQuery(), instanceOf(TermsQuery.class));
assertThat(booleanQuery.clauses().get(1).getQuery(), instanceOf(GenericFunctionQuery.class));
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class ExpressionAnalyzerTest method testSwapFunctionLeftSide.
@Test
public void testSwapFunctionLeftSide() throws Exception {
SqlExpressions expressions = new SqlExpressions(T3.SOURCES);
Function cmp = (Function) expressions.normalize(expressions.asSymbol("8 + 5 > t1.x"));
// the comparison was swapped so the field is on the left side
assertThat(cmp.info().ident().name(), is("op_<"));
assertThat(cmp.arguments().get(0), isField("x"));
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class ExpressionAnalyzerTest method testBetweenIsRewrittenToLteAndGte.
@Test
public void testBetweenIsRewrittenToLteAndGte() throws Exception {
SqlExpressions expressions = new SqlExpressions(T3.SOURCES);
Symbol symbol = expressions.asSymbol("10 between 1 and 10");
assertThat(symbol, isSQL("((10 >= 1) AND (10 <= 10))"));
}
use of io.crate.testing.SqlExpressions in project crate by crate.
the class LuceneQueryBuilderTest method testEqOnTwoArraysBecomesGenericFunctionQueryAllValuesNull.
@Test
public void testEqOnTwoArraysBecomesGenericFunctionQueryAllValuesNull() throws Exception {
SqlExpressions sqlExpressions = new SqlExpressions(sources, new Object[] { new Object[] { null, null, null } });
Query query = convert(new WhereClause(expressions.normalize(sqlExpressions.asSymbol("y_array = ?"))));
assertThat(query, instanceOf(GenericFunctionQuery.class));
}
Aggregations