Search in sources :

Example 1 with Limit

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

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 = new Limit(childPOP, first, last);
    return creator.addMetadata(this, limit);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) Limit(org.apache.drill.exec.physical.config.Limit)

Example 2 with Limit

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

the class TestLimitOperator method testLimitWithNegativeFirstLast.

@Test
public void testLimitWithNegativeFirstLast() {
    Limit limitConf = new Limit(null, -1, -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").expectZeroRows().go();
}
Also used : Limit(org.apache.drill.exec.physical.config.Limit) Test(org.junit.Test)

Example 3 with Limit

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

the class TestLimitOperator method testLimitWithNegativeOffset.

@Test
public void testLimitWithNegativeOffset() {
    Limit limitConf = new Limit(null, -1, null);
    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).baselineValues(5l, 5l).baselineValues(3l, 8l).go();
}
Also used : Limit(org.apache.drill.exec.physical.config.Limit) Test(org.junit.Test)

Example 4 with Limit

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

the class TestLimitOperator method testLimitMoreRecords.

@Test
public void testLimitMoreRecords() {
    Limit limitConf = new Limit(null, 0, 10);
    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).baselineValues(5l, 5l).baselineValues(3l, 8l).go();
}
Also used : Limit(org.apache.drill.exec.physical.config.Limit) Test(org.junit.Test)

Example 5 with Limit

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

the class TestLimitOperator method testLimitWithNoLastRecord.

@Test
public void testLimitWithNoLastRecord() {
    Limit limitConf = new Limit(null, 1, null);
    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, 5l).baselineValues(3l, 8l).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