Esempio n. 1
0
  @Override
  protected RelationPlan visitSampledRelation(SampledRelation node, Void context) {
    if (node.getColumnsToStratifyOn().isPresent()) {
      throw new UnsupportedOperationException("STRATIFY ON is not yet implemented");
    }

    RelationPlan subPlan = process(node.getRelation(), context);

    TupleDescriptor outputDescriptor = analysis.getOutputDescriptor(node);
    double ratio = analysis.getSampleRatio(node);
    Symbol sampleWeightSymbol = null;
    if (node.getType() == SampledRelation.Type.POISSONIZED) {
      sampleWeightSymbol = symbolAllocator.newSymbol("$sampleWeight", BIGINT);
    }
    PlanNode planNode =
        new SampleNode(
            idAllocator.getNextId(),
            subPlan.getRoot(),
            ratio,
            SampleNode.Type.fromType(node.getType()),
            node.isRescaled(),
            Optional.ofNullable(sampleWeightSymbol));
    return new RelationPlan(
        planNode,
        outputDescriptor,
        subPlan.getOutputSymbols(),
        Optional.ofNullable(sampleWeightSymbol));
  }