SAMPLE_UNIFORM()

All functions > BUSINESS > SAMPLE_UNIFORM()

Returns a value uniformly chosen between two bounds based on the given hashing key.

Signatures

Returns: Deterministic value uniformly distributed in [lower, upper]

SAMPLE_UNIFORM(hashing_key: VARCHAR, lower: DOUBLE, upper: DOUBLE) → DOUBLE
sql
ParameterTypeRequiredDescription
hashing_keyVARCHARYesString value to hash (typically user ID or session ID)
lowerDOUBLEYesLower bound of uniform distribution (inclusive)
upperDOUBLEYesUpper bound of uniform distribution (inclusive)

Notes

  • Deterministic - same key always produces same value
  • Uses HASH01 internally scaled to [lower, upper] range
  • Uniformly distributed between bounds
  • Useful for A/B testing with continuous values
  • Each unique key maps to stable value in range
  • Common for price experiments, discount simulations

Examples

FeatureQL
SELECT
    f1 := SAMPLE_UNIFORM('k', 5E0, 15E0) -- Uniform draw between bounds for a fixed key
;
Result
f1 VARCHAR
10.503645788728218

Last update at: 2026/05/26 17:22:09