use of io.crate.analyze.QuerySpec in project crate by crate.
the class RelationSplitterTest method testSplitNotMultiRelation.
@Test
public void testSplitNotMultiRelation() throws Exception {
QuerySpec querySpec = fromQuery("not (a = 1 and x = 2) and b = 2");
RelationSplitter splitter = split(querySpec);
assertThat(querySpec, isSQL("SELECT true"));
assertThat(splitter.getSpec(T3.TR_1), isSQL("SELECT WHERE (NOT ((doc.t1.a = '1') AND (doc.t1.x = 2)))"));
assertThat(splitter.getSpec(T3.TR_2), isSQL("SELECT WHERE (true AND (doc.t2.b = '2'))"));
}
use of io.crate.analyze.QuerySpec in project crate by crate.
the class RelationSplitterTest method testSplitOfSingleRelationTree.
@Test
public void testSplitOfSingleRelationTree() throws Exception {
QuerySpec querySpec = fromQuery("t1.a = t2.b and t1.a = 'employees'");
RelationSplitter splitter = split(querySpec);
assertThat(querySpec, isSQL("SELECT true WHERE ((doc.t1.a = doc.t2.b) AND true)"));
assertThat(splitter.getSpec(T3.TR_1), isSQL("SELECT doc.t1.a WHERE (doc.t1.a = 'employees')"));
assertThat(splitter.getSpec(T3.TR_2), isSQL("SELECT doc.t2.b"));
}
use of io.crate.analyze.QuerySpec in project crate by crate.
the class RelationSplitterTest method testSplitNotMultiRelationInside.
@Test
public void testSplitNotMultiRelationInside() throws Exception {
QuerySpec querySpec = fromQuery("not (a = 1 and b = 2)");
assertThat(querySpec, isSQL("SELECT true WHERE (NOT ((doc.t1.a = '1') AND (doc.t2.b = '2')))"));
RelationSplitter splitter = split(querySpec);
assertThat(querySpec, isSQL("SELECT true WHERE (NOT ((doc.t1.a = '1') AND (doc.t2.b = '2')))"));
assertThat(splitter.getSpec(T3.TR_1), isSQL("SELECT doc.t1.a"));
assertThat(splitter.getSpec(T3.TR_2), isSQL("SELECT doc.t2.b"));
}
use of io.crate.analyze.QuerySpec in project crate by crate.
the class RelationSplitterTest method testScoreCannotBeFetchd.
@Test
public void testScoreCannotBeFetchd() throws Exception {
QuerySpec querySpec = new QuerySpec().outputs(Arrays.asList(asSymbol("t1._score"), asSymbol("a")));
RelationSplitter splitter = split(querySpec);
assertThat(splitter.canBeFetched(), containsInAnyOrder(asSymbol("a")));
}
use of io.crate.analyze.QuerySpec in project crate by crate.
the class RelationSplitterTest method testMatchWithColumnsFrom2Relations.
@Test
public void testMatchWithColumnsFrom2Relations() throws Exception {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Must not use columns from more than 1 relation inside the MATCH predicate");
QuerySpec querySpec = fromQuery("match ((a, b), 'search term')");
split(querySpec);
}
Aggregations