public PlanNode rewriteTopN(TopNNode node, Void context, PlanRewriter<Void> planRewriter)
{
PlanNode source = planRewriter.rewrite(node.getSource(), null);
if (source instanceof MaterializeSampleNode) {
node = new TopNNode(node.getId(), ((MaterializeSampleNode) source).getSource(), node.getCount(), node.getOrderBy(), node.getOrderings(), node.isPartial(), Optional.of(((MaterializeSampleNode) source).getSampleWeightSymbol()));
return new MaterializeSampleNode(source.getId(), node, ((MaterializeSampleNode) source).getSampleWeightSymbol());
}
else {
return planRewriter.defaultRewrite(node, null);
}
}