You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2023/08/10 18:53:00 UTC
[jira] [Created] (CALCITE-5916) In RelBuilder, add sample() method (equivalent to SQL TABLESAMPLE clause)
Julian Hyde created CALCITE-5916:
------------------------------------
Summary: 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
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)