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);
}
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);
}
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();
}
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();
}
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();
}
Aggregations