use of io.crate.analyze.relations.QueriedDocTable in project crate by crate.
the class QueriedDocTableFetchPushDownTest method testPushDownWithOrder.
@Test
public void testPushDownWithOrder() throws Exception {
QuerySpec qs = new QuerySpec();
qs.outputs(Lists.newArrayList(REF_A, REF_I));
qs.orderBy(new OrderBy(Lists.newArrayList(REF_I), new boolean[] { true }, new Boolean[] { false }));
QueriedDocTableFetchPushDown pd = new QueriedDocTableFetchPushDown(new QueriedDocTable(TABLE_REL, qs));
QueriedDocTable sub = pd.pushDown();
assertThat(qs, isSQL("SELECT FETCH(INPUT(0), s.t._doc['a']), INPUT(1) ORDER BY INPUT(1) DESC NULLS LAST"));
assertThat(sub.querySpec(), isSQL("SELECT s.t._fetchid, s.t.i ORDER BY s.t.i DESC NULLS LAST"));
}
use of io.crate.analyze.relations.QueriedDocTable in project crate by crate.
the class QueriedDocTableFetchPushDownTest method testScoreDoesNotRequireFetch.
@Test
public void testScoreDoesNotRequireFetch() throws Exception {
QuerySpec qs = new QuerySpec();
qs.outputs(Lists.newArrayList(REF_I, REF_SCORE));
qs.orderBy(new OrderBy(ImmutableList.of(REF_I), new boolean[] { true }, new Boolean[] { false }));
QueriedDocTableFetchPushDown pd = new QueriedDocTableFetchPushDown(new QueriedDocTable(TABLE_REL, qs));
assertNull(pd.pushDown());
}
use of io.crate.analyze.relations.QueriedDocTable in project crate by crate.
the class QueriedDocTableFetchPushDownTest method testNoPushDownWithOrder.
@Test
public void testNoPushDownWithOrder() throws Exception {
QuerySpec qs = new QuerySpec();
qs.outputs(Lists.newArrayList(REF_I));
qs.orderBy(new OrderBy(ImmutableList.of(REF_I), new boolean[] { true }, new Boolean[] { false }));
QueriedDocTableFetchPushDown pd = new QueriedDocTableFetchPushDown(new QueriedDocTable(TABLE_REL, qs));
assertNull(pd.pushDown());
assertThat(qs, isSQL("SELECT s.t.i ORDER BY s.t.i DESC NULLS LAST"));
}
use of io.crate.analyze.relations.QueriedDocTable in project crate by crate.
the class QueriedDocTableFetchPushDownTest method testLimitIsPushedDown.
@Test
public void testLimitIsPushedDown() throws Exception {
QuerySpec qs = new QuerySpec();
qs.outputs(Lists.newArrayList(REF_I, REF_A));
qs.limit(Optional.of(Literal.of(10)));
qs.offset(Optional.of(Literal.of(100)));
QueriedDocTableFetchPushDown pd = new QueriedDocTableFetchPushDown(new QueriedDocTable(TABLE_REL, qs));
QueriedDocTable sub = pd.pushDown();
assertThat(sub.querySpec().limit().get(), is(Literal.of(10)));
assertThat(sub.querySpec().offset().get(), is(Literal.of(100)));
assertThat(qs.limit().get(), is(Literal.of(10)));
assertThat(qs.offset().get(), is(Literal.of(100)));
}
use of io.crate.analyze.relations.QueriedDocTable in project crate by crate.
the class QueriedDocTableFetchPushDownTest method testWhereIsPushedDown.
@Test
public void testWhereIsPushedDown() throws Exception {
QuerySpec qs = new QuerySpec();
qs.outputs(Lists.newArrayList(REF_I, REF_A));
qs.where(WhereClause.NO_MATCH);
QueriedDocTableFetchPushDown pd = new QueriedDocTableFetchPushDown(new QueriedDocTable(TABLE_REL, qs));
QueriedDocTable sub = pd.pushDown();
assertThat(sub.querySpec().where(), is(WhereClause.NO_MATCH));
assertThat(qs.where(), is(WhereClause.MATCH_ALL));
}
Aggregations