Miscellaneous Functions

In this Topic:

Utility Functions

Data Generation Functions

General Usage Notes

  • Sequences generated by these functions may not be ordered, and may not be gap-free. This is because numbers may be generated in parallel, in an unsynchronized fashion. If an ordered, gap-free sequence is required, the global degree of parallelism of the query must be set to 1 through suitable session parameters and/or warehouse configuration.

    For more details about sequences in Snowflake, see Using Sequences.

Random Distribution Functions

General Usage Notes

  • Random distribution functions are deterministic.
  • Each random distribution function takes a generator expression, gen, as its last argument. The generator expression, gen, can be constant or variable:
    • If constant, then the result of the random distribution function will also be constant (unless there are other, variable arguments, which is currently only supported for RANDSTR).
    • If variable, then the result of the random distribution function will also be variable.
  • Generator expressions are always of type 64-bit integer and implicit conversions may apply. Any expression that can be converted into a 64-bit integer may be used as a generator expression.
  • The randomness of any random distribution function is directly linked to the randomness of its generator expression. For most practical purposes, the RANDOM data generation function is the best choice for randomly-generated integer values.