test: Add verification of deterministic and collision-resistant properties of PartitionHashId

pull/24376/head
Carol (Nichols || Goulding) 2023-06-21 13:32:44 -04:00
parent 5096164efb
commit 0d9f89ae48
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
1 changed files with 9 additions and 0 deletions

View File

@ -416,6 +416,15 @@ mod tests {
let partition_hash_id = PartitionHashId::new(table_id, &partition_key);
// ID generation MUST be deterministic.
let partition_hash_id_regenerated = PartitionHashId::new(table_id, &partition_key);
assert_eq!(partition_hash_id, partition_hash_id_regenerated);
// ID generation MUST be collision resistant; different inputs -> different IDs
let other_table_id = TableId::new(table_id.get().wrapping_add(1));
let different_partition_hash_id = PartitionHashId::new(other_table_id, &partition_key);
assert_ne!(partition_hash_id, different_partition_hash_id);
// The bytes of the partition hash ID are stored in the catalog and sent from the
// ingesters to the queriers. We should be able to round-trip through bytes.
let bytes_representation = partition_hash_id.as_bytes();