[
https://issues.apache.org/jira/browse/CALCITE-5916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17753557#comment-17753557
]
LakeShen commented on CALCITE-5916:
-----------------------------------
After CALCITE-5895 merged,I would do this.
Hi [~julianhyde] ,could you help me review the PR of CALCITE-5895 again? I have
modified the code as suggested,thank you so much.
> 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
> Priority: Major
>
> 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)