Skip to content

Commit

Permalink
Merge branch 'main' into implement_sign
Browse files Browse the repository at this point in the history
  • Loading branch information
ngrislain authored Nov 20, 2023
2 parents a6fa164 + c322287 commit 05fd357
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
## Added
- `SIGN` funtion [#194](https://github.com/Qrlew/qrlew/issues/194)

## [0.5.2] - 2023-11-19
## Added
- `CEIL`, `ROUND`, `FLOOR`and `TRUNC` funtions [#192](https://github.com/Qrlew/qrlew/issues/192)
- `SIGN` funtion [#194](https://github.com/Qrlew/qrlew/issues/194)
- SD is acceptable as DP compilation

## [0.5.1] - 2023-11-19
## Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Nicolas Grislain <ng@sarus.tech>"]
name = "qrlew"
version = "0.5.1"
version = "0.5.2"
edition = "2021"
description = "Sarus Qrlew Engine"
documentation = "https://docs.rs/qrlew"
Expand Down
2 changes: 1 addition & 1 deletion src/rewriting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl Relation {
.select_rewriting_rules(RewritingRulesSelector)
.into_iter()
.filter_map(|rwrr| match rwrr.attributes().output() {
Property::Public | Property::Published | Property::DifferentiallyPrivate => {
Property::Public | Property::Published | Property::DifferentiallyPrivate | Property::SyntheticData => {
Some((rwrr.rewrite(Rewriter::new(relations)), rwrr.accept(Score)))
}
property => None,
Expand Down
59 changes: 59 additions & 0 deletions src/rewriting/rewriting_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,4 +1439,63 @@ mod tests {
.unwrap();
}
}

#[test]
fn test_set_eliminate_select_rewriting_rules_synthetic() {
let database = postgresql::test_database();
let relations = database.relations();
// Print relations with paths
for (p, r) in relations.iter() {
println!("{} -> {r}", p.into_iter().join("."))
}
let query = parse(
"SELECT order_id, price FROM item_table WHERE order_id IN (1,2,3,4,5,6,7,8,9,10)",
)
.unwrap();
let synthetic_data = SyntheticData::new(Hierarchy::from([
(vec!["item_table"], Identifier::from("item_table")),
(vec!["order_table"], Identifier::from("order_table")),
(vec!["user_table"], Identifier::from("user_table")),
]));
let privacy_unit = PrivacyUnit::from(vec![
(
"item_table",
vec![
("order_id", "order_table", "id"),
("user_id", "user_table", "id"),
],
"name",
),
("order_table", vec![("user_id", "user_table", "id")], "name"),
("user_table", vec![], "name"),
]);
let budget = Budget::new(1., 1e-3);
let relation = Relation::try_from(query.with(&relations)).unwrap();
relation.display_dot().unwrap();
// Add rewritting rules
let relation_with_rules = relation.set_rewriting_rules(RewritingRulesSetter::new(
&relations,
synthetic_data,
privacy_unit,
budget,
));
relation_with_rules.display_dot().unwrap();
let relation_with_rules = relation_with_rules.map_rewriting_rules(RewritingRulesEliminator);
relation_with_rules.display_dot().unwrap();
for rwrr in relation_with_rules.select_rewriting_rules(RewritingRulesSelector) {
rwrr.display_dot().unwrap();
let num_dp = rwrr.accept(BudgetDispatcher);
println!("DEBUG SPLIT BUDGET IN {}", num_dp);
println!("DEBUG SCORE {}", rwrr.accept(Score));
let relation_with_private_query = rwrr.rewrite(Rewriter(&relations));
println!(
"PrivateQuery: {:?}",
relation_with_private_query.private_query()
);
relation_with_private_query
.relation()
.display_dot()
.unwrap();
}
}
}

0 comments on commit 05fd357

Please sign in to comment.