presto-main/src/main/java/io/prestosql/sql/planner/iterative/rule/PushSampleIntoTableScan.java/PushSampleIntoTableScan/apply
class PushSampleIntoTableScan:    @Override
    public Rule.Result apply(SampleNode sample, Captures captures, Rule.Context context)
    {
        TableScanNode tableScan = captures.get(TABLE_SCAN);

        return metadata.applySample(context.getSession(), tableScan.getTable(), getSamplingType(sample.getSampleType()), sample.getSampleRatio())
                .map(result -> Result.ofPlanNode(new TableScanNode(
                        tableScan.getId(),
                        result,
                        tableScan.getOutputSymbols(),
                        tableScan.getAssignments(),
                        tableScan.getEnforcedConstraint())))
                .orElseGet(Result::empty);
    }