@Override protected Void visitSampledRelation(SampledRelation node, Integer indent) { process(node.getRelation(), indent); builder.append(" TABLESAMPLE ") .append(node.getType()) .append(" (") .append(node.getSamplePercentage()) .append(')'); return null; }
@Override protected Void visitSampledRelation(SampledRelation node, Integer indentLevel) { print(indentLevel, "TABLESAMPLE[" + node.getType() + " (" + node.getSamplePercentage() + ")]"); super.visitSampledRelation(node, indentLevel + 1); return null; }
@Override protected RelationPlan visitSampledRelation(SampledRelation node, Void context) { RelationPlan subPlan = process(node.getRelation(), context); double ratio = analysis.getSampleRatio(node); PlanNode planNode = new SampleNode(idAllocator.getNextId(), subPlan.getRoot(), ratio, SampleNode.Type.fromType(node.getType())); return new RelationPlan(planNode, analysis.getScope(node), subPlan.getFieldMappings()); }
@Override protected Void visitSampledRelation(SampledRelation node, Integer indent) { process(node.getRelation(), indent); builder.append(" TABLESAMPLE ") .append(node.getType()) .append(" (") .append(node.getSamplePercentage()) .append(')'); return null; }
@Override protected Void visitSampledRelation(SampledRelation node, Integer indent) { process(node.getRelation(), indent); builder.append(" TABLESAMPLE ") .append(node.getType()) .append(" (") .append(node.getSamplePercentage()) .append(')'); return null; }
@Override protected Void visitSampledRelation(SampledRelation node, Integer indentLevel) { print(indentLevel, "TABLESAMPLE[" + node.getType() + " (" + node.getSamplePercentage() + ")]"); super.visitSampledRelation(node, indentLevel + 1); return null; }
@Override protected Void visitSampledRelation(SampledRelation node, Integer indent) { process(node.getRelation(), indent); builder.append(" TABLESAMPLE ") .append(node.getType()) .append(" (") .append(node.getSamplePercentage()) .append(')'); if (node.getColumnsToStratifyOn().isPresent()) { builder.append(" STRATIFY ON ") .append(" (") .append(Joiner.on(",").join(node.getColumnsToStratifyOn().get())); builder.append(')'); } return null; }
@Override protected Void visitSampledRelation(SampledRelation node, Integer indent) { process(node.getRelation(), indent); builder.append(" TABLESAMPLE ") .append(node.getType()) .append(" (") .append(node.getSamplePercentage()) .append(')'); if (node.getColumnsToStratifyOn().isPresent()) { builder.append(" STRATIFY ON ") .append(" (") .append(Joiner.on(",").join(node.getColumnsToStratifyOn().get())); builder.append(')'); } return null; }
@Override protected Void visitSampledRelation(SampledRelation node, Integer indentLevel) { String stratifyOn = ""; if (node.getColumnsToStratifyOn().isPresent()) { stratifyOn = " STRATIFY ON (" + node.getColumnsToStratifyOn().get().toString() + ")"; } print(indentLevel, "TABLESAMPLE[" + node.getType() + " (" + node.getSamplePercentage() + ")" + stratifyOn + "]"); super.visitSampledRelation(node, indentLevel + 1); return null; }
@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); RelationType 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)); }
throw new SemanticException(SemanticErrorCode.SAMPLE_PERCENTAGE_OUT_OF_RANGE, relation.getSamplePercentage(), "Sample percentage must be greater than or equal to 0"); if ((samplePercentageValue > 100.0) && ((relation.getType() != SampledRelation.Type.POISSONIZED) || relation.isRescaled())) { throw new SemanticException(SemanticErrorCode.SAMPLE_PERCENTAGE_OUT_OF_RANGE, relation.getSamplePercentage(), "Sample percentage must be less than or equal to 100");