Skip to content

Commit

Permalink
docs(clickhouse): entry into the accursed (#10174)
Browse files Browse the repository at this point in the history
Random number generation is cursed in ClickHouse.
  • Loading branch information
cpcloud authored Sep 19, 2024
1 parent 1667f43 commit 5a2e6e8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/reference/cursed_knowledge.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@ execution engines.
* Impala's `LTRIM` and `RTRIM` functions accept a _set_ of whitespace (or other)
characters to remove from the left-, and right-hand-side sides of the input
string, but the `TRIM` function only removes _spaces_.

## ClickHouse

* [ClickHouse's random number generating
functions](https://clickhouse.com/docs/en/sql-reference/functions/random-functions)
are considered in [common subexpression
elimination](https://en.wikipedia.org/wiki/Common_subexpression_elimination),
so to get two unique random numbers, users must defeat that optimization.
This is done by passing **any** argument to those functions. It's left as an
exercise for the reader to figure out how to generate two unique inputs.

0 comments on commit 5a2e6e8

Please sign in to comment.