@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 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 R visitSampledRelation(SampledRelation node, C context) { process(node.getRelation(), context); process(node.getSamplePercentage(), context); if (node.getColumnsToStratifyOn().isPresent()) { for (Expression expression : node.getColumnsToStratifyOn().get()) { process(expression, context); } } 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)); }
@Override protected RelationType visitSampledRelation(SampledRelation relation, AnalysisContext context) if (relation.getColumnsToStratifyOn().isPresent()) { throw new SemanticException(NOT_SUPPORTED, relation, "STRATIFY ON is not yet implemented");