Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5916

In RelBuilder, add sample() method (equivalent to SQL TABLESAMPLE clause)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.36.0
    • 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

          Activity

            People

              julianhyde Julian Hyde
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: