Search in sources :

Example 11 with Limit

use of org.apache.drill.exec.physical.config.Limit in project drill by apache.

the class LimitPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator childPOP = child.getPhysicalOperator(creator);
    // First offset to include into results (inclusive). Null implies it is starting from offset 0
    int first = offset != null ? Math.max(0, RexLiteral.intValue(offset)) : 0;
    // Last offset to stop including into results (exclusive), translating fetch row counts into an offset.
    // Null value implies including entire remaining result set from first offset
    Integer last = fetch != null ? Math.max(0, RexLiteral.intValue(fetch)) + first : null;
    Limit limit;
    if (isPartitioned) {
        limit = new PartitionLimit(childPOP, first, last, DrillRelOptUtil.IMPLICIT_COLUMN);
    } else {
        limit = new Limit(childPOP, first, last);
    }
    return creator.addMetadata(this, limit);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) PartitionLimit(org.apache.drill.exec.physical.config.PartitionLimit) Limit(org.apache.drill.exec.physical.config.Limit) PartitionLimit(org.apache.drill.exec.physical.config.PartitionLimit)

Example 12 with Limit

use of org.apache.drill.exec.physical.config.Limit in project drill by axbaretto.

the class TestNullInputMiniPlan method testLimitEmpty.

@Test
public void testLimitEmpty() throws Exception {
    final PhysicalOperator limit = new Limit(null, 10, 5);
    testSingleInputNullBatchHandling(limit);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) Limit(org.apache.drill.exec.physical.config.Limit) Test(org.junit.Test)

Example 13 with Limit

use of org.apache.drill.exec.physical.config.Limit in project drill by apache.

the class TestLimitOperator method testLimitLessRecords.

@Test
public void testLimitLessRecords() {
    Limit limitConf = new Limit(null, 0, 1);
    List<String> inputJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]");
    legacyOpTestBuilder().physicalOperator(limitConf).inputDataStreamJson(inputJsonBatches).baselineColumns("a", "b").baselineValues(5l, 1l).go();
}
Also used : Limit(org.apache.drill.exec.physical.config.Limit) Test(org.junit.Test)

Example 14 with Limit

use of org.apache.drill.exec.physical.config.Limit in project drill by apache.

the class TestLimitOperator method testLimitWithOffset.

@Test
public void testLimitWithOffset() {
    Limit limitConf = new Limit(null, 2, 3);
    List<String> inputJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]");
    legacyOpTestBuilder().physicalOperator(limitConf).inputDataStreamJson(inputJsonBatches).baselineColumns("a", "b").baselineValues(3l, 8l).go();
}
Also used : Limit(org.apache.drill.exec.physical.config.Limit) Test(org.junit.Test)

Example 15 with Limit

use of org.apache.drill.exec.physical.config.Limit in project drill by apache.

the class TestLimitOperator method testLimitWithOffsetOutOfRange.

@Test
public void testLimitWithOffsetOutOfRange() {
    Limit limitConf = new Limit(null, 10, 20);
    List<String> inputJsonBatches = Lists.newArrayList("[{\"a\": 5, \"b\" : 1 }]", "[{\"a\": 5, \"b\" : 5},{\"a\": 3, \"b\" : 8}]");
    legacyOpTestBuilder().physicalOperator(limitConf).inputDataStreamJson(inputJsonBatches).baselineColumns("a", "b").expectZeroRows().go();
}
Also used : Limit(org.apache.drill.exec.physical.config.Limit) Test(org.junit.Test)

Aggregations

Limit (org.apache.drill.exec.physical.config.Limit)17 Test (org.junit.Test)15 OperatorTest (org.apache.drill.categories.OperatorTest)6 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)6 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)4 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)3 PartitionLimit (org.apache.drill.exec.physical.config.PartitionLimit)1