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