use of io.prestosql.spi.plan.LimitNode in project hetu-core by openlookeng.
the class PushLimitThroughOffset method apply.
@Override
public Result apply(LimitNode parent, Captures captures, Context context) {
OffsetNode child = captures.get(CHILD);
long count;
try {
count = addExact(parent.getCount(), child.getCount());
} catch (ArithmeticException e) {
return Result.empty();
}
return Result.ofPlanNode(child.replaceChildren(ImmutableList.of(new LimitNode(parent.getId(), child.getSource(), count, parent.getTiesResolvingScheme(), parent.isPartial()))));
}
use of io.prestosql.spi.plan.LimitNode in project hetu-core by openlookeng.
the class TransformExistsApplyToLateralNode method rewriteToNonDefaultAggregation.
private Optional<PlanNode> rewriteToNonDefaultAggregation(ApplyNode applyNode, Context context) {
checkState(applyNode.getSubquery().getOutputSymbols().isEmpty(), "Expected subquery output symbols to be pruned");
Symbol exists = getOnlyElement(applyNode.getSubqueryAssignments().getSymbols());
Symbol subqueryTrue = context.getSymbolAllocator().newSymbol("subqueryTrue", BOOLEAN);
Assignments.Builder assignments = Assignments.builder();
assignments.putAll(AssignmentUtils.identityAsSymbolReferences(applyNode.getInput().getOutputSymbols()));
assignments.put(exists, castToRowExpression(new CoalesceExpression(ImmutableList.of(toSymbolReference(subqueryTrue), BooleanLiteral.FALSE_LITERAL))));
PlanNode subquery = new ProjectNode(context.getIdAllocator().getNextId(), new LimitNode(context.getIdAllocator().getNextId(), applyNode.getSubquery(), 1L, false), Assignments.of(subqueryTrue, castToRowExpression(TRUE_LITERAL)));
PlanNodeDecorrelator decorrelator = new PlanNodeDecorrelator(context.getIdAllocator(), context.getLookup());
if (!decorrelator.decorrelateFilters(subquery, applyNode.getCorrelation()).isPresent()) {
return Optional.empty();
}
return Optional.of(new ProjectNode(context.getIdAllocator().getNextId(), new LateralJoinNode(applyNode.getId(), applyNode.getInput(), subquery, applyNode.getCorrelation(), LEFT, TRUE_LITERAL, applyNode.getOriginSubquery()), assignments.build()));
}
use of io.prestosql.spi.plan.LimitNode in project hetu-core by openlookeng.
the class PushLimitThroughOuterJoin method apply.
@Override
public Result apply(LimitNode parent, Captures captures, Context context) {
JoinNode joinNode = captures.get(CHILD);
PlanNode left = joinNode.getLeft();
PlanNode right = joinNode.getRight();
if (joinNode.getType() == LEFT && !isAtMost(left, context.getLookup(), parent.getCount())) {
return Result.ofPlanNode(parent.replaceChildren(ImmutableList.of(joinNode.replaceChildren(ImmutableList.of(new LimitNode(context.getIdAllocator().getNextId(), left, parent.getCount(), true), right)))));
}
if (joinNode.getType() == RIGHT && !isAtMost(right, context.getLookup(), parent.getCount())) {
return Result.ofPlanNode(parent.replaceChildren(ImmutableList.of(joinNode.replaceChildren(ImmutableList.of(left, new LimitNode(context.getIdAllocator().getNextId(), right, parent.getCount(), true))))));
}
return Result.empty();
}
use of io.prestosql.spi.plan.LimitNode in project hetu-core by openlookeng.
the class TestEffectivePredicateExtractor method testLimit.
@Test
public void testLimit() {
PlanNode node = new LimitNode(newId(), filter(baseTableScan, and(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10)))), 1, false);
Expression effectivePredicate = effectivePredicateExtractor.extract(SESSION, node, TypeProvider.empty(), typeAnalyzer);
// Pass through
assertEquals(normalizeConjuncts(effectivePredicate), normalizeConjunctsSet(equals(AE, BE), equals(BE, CE), lessThan(CE, bigintLiteral(10))));
}
use of io.prestosql.spi.plan.LimitNode in project boostkit-bigdata by kunpengcompute.
the class TestHiveLimitPushdown method testLimitPushdown.
@Test
public void testLimitPushdown() {
int count = 5;
HiveLimitPushdown optimizer = new HiveLimitPushdown(simulationHiveTransactionManager());
TableScanNode tableScanNode = buildTableScanNode();
LimitNode limitNode = buildPartialLimitNode(tableScanNode, count);
PlanNode node = optimizer.optimize(limitNode, OFFLOAD_SESSION, COLUMN_TYPE_MAP, SYMBOL_ALLOCATOR, ID_ALLOCATOR);
matchLimitOffload(node, count);
}
Aggregations