SAMPLE_BOOL
All functions > BUSINESS > SAMPLE_BOOL
Returns the discrete event (true or false) with the given probability based on the given hashing key.
Signatures
Returns: Deterministic TRUE/FALSE based on probability threshold
SAMPLE_BOOL(hashing_key: VARCHAR, probability: DOUBLE) → BOOLEAN sql
| Parameter | Type | Required | Description |
|---|---|---|---|
hashing_key | VARCHAR | Yes | String value to hash (typically user ID or session ID) |
probability | DOUBLE | Yes | Probability of TRUE result (between 0.0 and 1.0) |
Notes
- Deterministic - same key always produces same result
- Returns TRUE with given probability, FALSE otherwise
- Uses HASH01 internally compared against probability threshold
- Probability should be between 0.0 (never) and 1.0 (always)
- Useful for A/B testing, feature flags, random sampling
- Common for conversion simulations, user assignments
On this page