From c322287a87b0b4ba957bffa464e2e9f4a30b495e Mon Sep 17 00:00:00 2001 From: Nicolas Grislain Date: Mon, 20 Nov 2023 22:13:44 +0100 Subject: [PATCH] Update version and mae SD ok for DP --- CHANGELOG.md | 4 +++ Cargo.toml | 2 +- src/rewriting/mod.rs | 2 +- src/rewriting/rewriting_rule.rs | 59 +++++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2af7cdf9..bf6e8c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## Added + +## [0.5.2] - 2023-11-19 +## Added - `CEIL`, `ROUND`, `FLOOR`and `TRUNC` funtions [#192](https://github.com/Qrlew/qrlew/issues/192) +- SD is acceptable as DP compilation ## [0.5.1] - 2023-11-19 ## Added diff --git a/Cargo.toml b/Cargo.toml index 1881b595..efb67998 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["Nicolas Grislain "] name = "qrlew" -version = "0.5.1" +version = "0.5.2" edition = "2021" description = "Sarus Qrlew Engine" documentation = "https://docs.rs/qrlew" diff --git a/src/rewriting/mod.rs b/src/rewriting/mod.rs index a02275dc..047a0209 100644 --- a/src/rewriting/mod.rs +++ b/src/rewriting/mod.rs @@ -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, diff --git a/src/rewriting/rewriting_rule.rs b/src/rewriting/rewriting_rule.rs index cf3c1332..82950eb3 100644 --- a/src/rewriting/rewriting_rule.rs +++ b/src/rewriting/rewriting_rule.rs @@ -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(); + } + } }