@Override public Map<PlanNodeId, SplitSource> visitSample(SampleNode node, Void context) { switch (node.getSampleType()) { case BERNOULLI: return node.getSource().accept(this, context); case SYSTEM: Map<PlanNodeId, SplitSource> nodeSplits = node.getSource().accept(this, context); // TODO: when this happens we should switch to either BERNOULLI or page sampling if (nodeSplits.size() == 1) { PlanNodeId planNodeId = getOnlyElement(nodeSplits.keySet()); SplitSource sampledSplitSource = new SampledSplitSource(nodeSplits.get(planNodeId), node.getSampleRatio()); return ImmutableMap.of(planNodeId, sampledSplitSource); } // table sampling on a sub query without splits is meaningless return nodeSplits; default: throw new UnsupportedOperationException("Sampling is not supported for type " + node.getSampleType()); } }
@Override public Optional<SplitSource> visitSample(SampleNode node, Void context) { switch (node.getSampleType()) { case BERNOULLI: case POISSONIZED: return node.getSource().accept(this, context); case SYSTEM: Optional<SplitSource> nodeSplits = node.getSource().accept(this, context); if (nodeSplits.isPresent()) { SplitSource sampledSplitSource = new SampledSplitSource(nodeSplits.get(), node.getSampleRatio()); return Optional.of(sampledSplitSource); } // table sampling on a sub query without splits is meaningless return nodeSplits; default: throw new UnsupportedOperationException("Sampling is not supported for type " + node.getSampleType()); } }