Search in sources :

Example 11 with QuerySpec

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")));
}
Also used : QuerySpec(io.crate.analyze.QuerySpec) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 12 with QuerySpec

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);
}
Also used : QuerySpec(io.crate.analyze.QuerySpec) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 13 with QuerySpec

use of io.crate.analyze.QuerySpec in project crate by crate.

the class SelectPlannerTest method testNoSoftLimitOnUnlimitedChildRelation.

@Test
public void testNoSoftLimitOnUnlimitedChildRelation() throws Exception {
    int softLimit = 10_000;
    EvaluatingNormalizer normalizer = EvaluatingNormalizer.functionOnlyNormalizer(e.functions(), ReplaceMode.COPY);
    Planner.Context plannerContext = new Planner.Context(e.planner, clusterService, UUID.randomUUID(), null, normalizer, new TransactionContext(SessionContext.SYSTEM_SESSION), softLimit, 0);
    Limits limits = plannerContext.getLimits(new QuerySpec());
    assertThat(limits.finalLimit(), is(TopN.NO_LIMIT));
}
Also used : SessionContext(io.crate.action.sql.SessionContext) EvaluatingNormalizer(io.crate.analyze.EvaluatingNormalizer) QuerySpec(io.crate.analyze.QuerySpec) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 14 with QuerySpec

use of io.crate.analyze.QuerySpec 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"));
}
Also used : OrderBy(io.crate.analyze.OrderBy) QueriedDocTable(io.crate.analyze.relations.QueriedDocTable) QuerySpec(io.crate.analyze.QuerySpec) Test(org.junit.Test)

Example 15 with QuerySpec

use of io.crate.analyze.QuerySpec 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());
}
Also used : OrderBy(io.crate.analyze.OrderBy) QueriedDocTable(io.crate.analyze.relations.QueriedDocTable) QuerySpec(io.crate.analyze.QuerySpec) Test(org.junit.Test)

Aggregations

QuerySpec (io.crate.analyze.QuerySpec)31 Test (org.junit.Test)25 CrateUnitTest (io.crate.test.integration.CrateUnitTest)15 OrderBy (io.crate.analyze.OrderBy)13 QueriedDocTable (io.crate.analyze.relations.QueriedDocTable)11 Symbol (io.crate.analyze.symbol.Symbol)4 Function (io.crate.analyze.symbol.Function)3 AbsFunction (io.crate.operation.scalar.arithmetic.AbsFunction)2 Nullable (javax.annotation.Nullable)2 SessionContext (io.crate.action.sql.SessionContext)1 EvaluatingNormalizer (io.crate.analyze.EvaluatingNormalizer)1 RelationSource (io.crate.analyze.RelationSource)1 QueriedRelation (io.crate.analyze.relations.QueriedRelation)1 Field (io.crate.analyze.symbol.Field)1 SelectSymbol (io.crate.analyze.symbol.SelectSymbol)1 DocKeys (io.crate.analyze.where.DocKeys)1 ValidationException (io.crate.exceptions.ValidationException)1 VersionInvalidException (io.crate.exceptions.VersionInvalidException)1 Reference (io.crate.metadata.Reference)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1