Search in sources :

Example 16 with QueriedDocTable

use of io.crate.analyze.relations.QueriedDocTable in project crate by crate.

the class QueriedDocTableFetchPushDownTest method testPushDownWithNestedOrderInOutput.

@Test
public void testPushDownWithNestedOrderInOutput() throws Exception {
    QuerySpec qs = new QuerySpec();
    Function funcOfI = abs(REF_I);
    qs.outputs(Lists.newArrayList(REF_A, REF_I, funcOfI));
    qs.orderBy(new OrderBy(Lists.newArrayList(funcOfI), 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']), FETCH(INPUT(0), s.t._doc['i']), INPUT(1) ORDER BY INPUT(1) DESC NULLS LAST"));
    assertThat(sub.querySpec(), isSQL("SELECT s.t._fetchid, abs(s.t.i) ORDER BY abs(s.t.i) DESC NULLS LAST"));
}
Also used : OrderBy(io.crate.analyze.OrderBy) Function(io.crate.analyze.symbol.Function) AbsFunction(io.crate.operation.scalar.arithmetic.AbsFunction) QueriedDocTable(io.crate.analyze.relations.QueriedDocTable) QuerySpec(io.crate.analyze.QuerySpec) Test(org.junit.Test)

Aggregations

QueriedDocTable (io.crate.analyze.relations.QueriedDocTable)16 Test (org.junit.Test)14 QuerySpec (io.crate.analyze.QuerySpec)11 OrderBy (io.crate.analyze.OrderBy)8 CrateUnitTest (io.crate.test.integration.CrateUnitTest)4 Function (io.crate.analyze.symbol.Function)2 AbsFunction (io.crate.operation.scalar.arithmetic.AbsFunction)2 ExpressionAnalysisContext (io.crate.analyze.expressions.ExpressionAnalysisContext)1 ExpressionAnalyzer (io.crate.analyze.expressions.ExpressionAnalyzer)1 DocTableRelation (io.crate.analyze.relations.DocTableRelation)1 Symbol (io.crate.analyze.symbol.Symbol)1 UnsupportedFeatureException (io.crate.exceptions.UnsupportedFeatureException)1 Reference (io.crate.metadata.Reference)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 TableInfo (io.crate.metadata.table.TableInfo)1 WriterProjection (io.crate.planner.projection.WriterProjection)1 Nullable (javax.annotation.Nullable)1 Settings (org.elasticsearch.common.settings.Settings)1