use of io.prestosql.sql.planner.plan.RowNumberNode in project hetu-core by openlookeng.
the class ImplementOffset method apply.
@Override
public Result apply(OffsetNode parent, Captures captures, Context context) {
Symbol rowNumberSymbol = context.getSymbolAllocator().newSymbol("row_number", BIGINT);
RowNumberNode rowNumberNode = new RowNumberNode(context.getIdAllocator().getNextId(), parent.getSource(), ImmutableList.of(), rowNumberSymbol, Optional.empty(), Optional.empty());
FilterNode filterNode = new FilterNode(context.getIdAllocator().getNextId(), rowNumberNode, castToRowExpression(new ComparisonExpression(ComparisonExpression.Operator.GREATER_THAN, toSymbolReference(rowNumberSymbol), new GenericLiteral("BIGINT", Long.toString(parent.getCount())))));
ProjectNode projectNode = new ProjectNode(context.getIdAllocator().getNextId(), filterNode, AssignmentUtils.identityAsSymbolReferences(parent.getOutputSymbols()));
return Result.ofPlanNode(projectNode);
}
use of io.prestosql.sql.planner.plan.RowNumberNode in project hetu-core by openlookeng.
the class RowNumberMatcher method detailMatches.
@Override
public MatchResult detailMatches(PlanNode node, StatsProvider stats, Session session, Metadata metadata, SymbolAliases symbolAliases) {
checkState(shapeMatches(node), "Plan testing framework error: shapeMatches returned false in detailMatches in %s", this.getClass().getName());
RowNumberNode rowNumberNode = (RowNumberNode) node;
if (partitionBy.isPresent()) {
List<Symbol> expected = partitionBy.get().stream().map(alias -> alias.toSymbol(symbolAliases)).collect(toImmutableList());
if (!expected.equals(rowNumberNode.getPartitionBy())) {
return NO_MATCH;
}
}
if (rowNumberSymbol.isPresent()) {
Symbol expected = rowNumberSymbol.get().toSymbol(symbolAliases);
if (!expected.equals(rowNumberNode.getRowNumberSymbol())) {
return NO_MATCH;
}
}
if (maxRowCountPerPartition.isPresent()) {
if (!maxRowCountPerPartition.get().equals(rowNumberNode.getMaxRowCountPerPartition())) {
return NO_MATCH;
}
}
if (hashSymbol.isPresent()) {
Optional<Symbol> expected = hashSymbol.get().map(alias -> alias.toSymbol(symbolAliases));
if (!expected.equals(rowNumberNode.getHashSymbol())) {
return NO_MATCH;
}
}
return match();
}
Aggregations