Implement `HashSet` Data type
cl-kim opened this issue · comments
cl-kim commented
Description
HashSet is a unordered collection type that stores unique values without duplicates. it ensures that the column only contains unique values, maintaining data integrity and consistency.
HashSet ensures that each value is unique within the collection. This property is beneficial when we need to store a set of distinct values in a column or data structure. HashSets do not have index. If you simply call a HashSet, the entire content of the set will be displayed.
Data Type
HASHSET
Example
DataType HASHSET
The following tests should be passed:
test_case!(hashset, async move {
run!(
"
CREATE TABLE SetType (
id INTEGER,
sets HASHSET
)"
);
test! {
name: "insert data",
sql: "INSERT INTO SetType VALUES
(1, {1,2,3,3}),
(2, {'a','b','c}])",
expected: Ok(Payload::Insert(2)),
}
test! {
name: "insert different type data in hashset",
sql: "INSERT INTO SetType VALUES (1, {1,2,'a'})",
expected: Err(ValueError::HashSetTypeRequiredSameDataTye.into())
}
test! {
name: "insert invalid data in hashset",
sql: "INSERT INTO SetType VALUES (1, "a")",
expected: Err(ValueError::HashSetTypeRequired.into())
}
test! {
name: "select query with hashSet column",
sql: "SELECT id, sets FROM SetType",
expected: Ok(select_with_null!(
id | sets;
I64(1) HashSet;
I64(2) HashSet;
))
}
});