Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
In RelBuilder, add sample() method (equivalent to SQL TABLESAMPLE clause).
In SqlToRelConverter, the 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); }
would become
relBuilder.push(bb.root());
relBuilder.sample(tableSampleSpec.isBernoulli(),
tableSampleSpec.getSamplePercentage(),
tableSampleSpec.isRepeatable(),
tableSampleSpec.getRepeatableSeed());
bb.setRoot(relBuilder.build(), false);
Note that RelBuilder.sample calls empty() if the rate = 0. It should also skip sampling if rate = 1.
Attachments
Issue Links
- is related to
-
CALCITE-5895 TABLESAMPLE(0) should return empty result
- Closed
- relates to
-
CALCITE-5912 Add an implementation of TABLESAMPLE in Enumerable convention
- In Progress