我有一个包含几个字段的表。第一个字段是userId
. 我正在使用哈希函数按 userId 对数据进行分片。
我正在运行以下查询:
SELECT userId, HASH(userId) as hashedId, HASH(userId) % 3 as hashedIdMod3
FROM mydataset.mytable LIMIT 1000
例如:
-5655326518438853587 % 3 ==> -1 when it should be 2
HASH(27315207816077732041734307321022553299) is -3139846784539570547 and the remainder is -2 when divided by 3 when it should be 1
那么,除以正整数时,余数怎么可能是负数呢?