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

Add RAND_INTEGER function, which returns a random integer modulo N

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.11.0
    • Component/s: None
    • Labels:

      Description

      Add a RANDOM function.
      It is not standard SQL, but most DBMSs have one, and it be useful.

      It will also allow us to better test non-deterministic expressions.

      I propose that:

      • RANDOM(n) returns an integer between 0 and n - 1 inclusive.
      • There is no facility to specify a seed at this time.
      • The random number generator is randomly seeded at query start time based on (say) the method used by Java's new Random(); if you run the query twice, you will (probably) not get the same results.
      • If you call the function twice in the same row, it will (probably) return different results.

        Attachments

        Issue Links

          Activity

            People

            • Assignee:
              julian.feinauer Julian Feinauer
              Reporter:
              julianhyde Julian Hyde

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment