[ https://issues.apache.org/jira/browse/CALCITE-5916?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Julian Hyde resolved CALCITE-5916. ---------------------------------- Fix Version/s: 1.36.0 Resolution: Fixed Fixed in [50c3edfc|https://github.com/apache/calcite/commit/50c3edfc3d6630528ab51fe836bd50df82cc7db8]. > In RelBuilder, add sample() method (equivalent to SQL TABLESAMPLE clause) > ------------------------------------------------------------------------- > > Key: CALCITE-5916 > URL: https://issues.apache.org/jira/browse/CALCITE-5916 > Project: Calcite > Issue Type: Bug > Reporter: Julian Hyde > Assignee: Julian Hyde > Priority: Major > Fix For: 1.36.0 > > > In RelBuilder, add sample() method (equivalent to SQL TABLESAMPLE clause). > In {{SqlToRelConverter}}, the code > {code} > if (tableSampleSpec.getSamplePercentage() == 0f) { > bb.setRoot(relBuilder.push(bb.root()).empty().build(), true); > } else { > RelOptSamplingParameters params = > new RelOptSamplingParameters( > tableSampleSpec.isBernoulli(), > tableSampleSpec.getSamplePercentage(), > tableSampleSpec.isRepeatable(), > tableSampleSpec.getRepeatableSeed()); > bb.setRoot(new Sample(cluster, bb.root(), params), false); > } > {code} > would become > {code} > relBuilder.push(bb.root()); > relBuilder.sample(tableSampleSpec.isBernoulli(), > tableSampleSpec.getSamplePercentage(), > tableSampleSpec.isRepeatable(), > tableSampleSpec.getRepeatableSeed()); > bb.setRoot(relBuilder.build(), false); > {code} > Note that {{RelBuilder.sample}} calls {{empty()}} if the rate = 0. It should > also skip sampling if rate = 1. -- This message was sent by Atlassian Jira (v8.20.10#820010)