2024-05-28 09:20:52 +00:00
|
|
|
-- Test SQL function 'generateSnowflakeID'
|
2024-05-23 18:38:30 +00:00
|
|
|
|
2024-05-22 15:59:39 +00:00
|
|
|
SELECT bitAnd(bitShiftRight(toUInt64(generateSnowflakeID()), 63), 1) = 0; -- check first bit is zero
|
2024-05-23 18:38:30 +00:00
|
|
|
SELECT generateSnowflakeID() = generateSnowflakeID(1); -- same as ^^
|
2024-07-11 04:29:09 +00:00
|
|
|
SELECT generateSnowflakeID(1) = generateSnowflakeID(2); -- disabled common subexpression elimination --> lhs != rhs
|
2024-07-14 16:41:24 +00:00
|
|
|
SELECT generateSnowflakeID(1) = generateSnowflakeID(1); -- enabled common subexpression elimination
|
2024-07-11 04:29:09 +00:00
|
|
|
|
|
|
|
SELECT generateSnowflakeID('expr', 1) = generateSnowflakeID('expr', 1); -- enabled common subexpression elimination
|
|
|
|
SELECT generateSnowflakeID('expr', 1) != generateSnowflakeID('expr', 2); -- different machine IDs should produce different results
|
2024-07-14 16:41:24 +00:00
|
|
|
|
|
|
|
SELECT bitAnd(generateSnowflakeID(1023), 1023) = 1023; -- check if the last 10 bits match the machine ID
|
|
|
|
|
2024-07-14 17:55:57 +00:00
|
|
|
SELECT generateSnowflakeID('invalid_machine_id'); -- no output for invalid type
|
2024-07-14 16:41:24 +00:00
|
|
|
|
2024-07-14 17:55:57 +00:00
|
|
|
SELECT generateSnowflakeID(materialize(toUInt64(1))); -- no output for non-const machine ID
|
2024-05-22 15:59:39 +00:00
|
|
|
|
|
|
|
SELECT count(*)
|
|
|
|
FROM
|
|
|
|
(
|
|
|
|
SELECT DISTINCT generateSnowflakeID()
|
|
|
|
FROM numbers(100)
|
|
|
|
);
|