Skip to content

Commit

Permalink
Fix repair_key and add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreSenellart committed Jan 22, 2024
1 parent 3e0381a commit 6c6e175
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/expected/repair_key.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
\set ECHO none
repair_key
------------

(1 row)

remove_provenance
-------------------

(1 row)

ground | round
--------+-------
dry | 0.550
wet | 0.450
(2 rows)

24 changes: 24 additions & 0 deletions test/sql/repair_key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
\set ECHO none
SET search_path TO provsql_test,provsql;

CREATE TABLE weather_conditions (dummy VARCHAR, weather VARCHAR,
ground VARCHAR, p FLOAT);
INSERT INTO weather_conditions VALUES ('dummy', 'rain', 'wet', 0.35);
INSERT INTO weather_conditions VALUES ('dummy', 'rain', 'dry', 0.05);
INSERT INTO weather_conditions VALUES ('dummy', 'no rain', 'wet', 0.1);
INSERT INTO weather_conditions VALUES ('dummy', 'no rain', 'dry', 0.5);

SELECT repair_key('weather_conditions','dummy');
DO $$ BEGIN
PERFORM set_prob(provenance(), p) FROM weather_conditions;
END $$;

CREATE TABLE result_repair_key AS
SELECT *, probability_evaluate(provenance()) prob FROM (
SELECT ground FROM weather_conditions GROUP BY ground) t;

SELECT remove_provenance('result_repair_key');
SELECT ground, ROUND(prob::numeric, 3) FROM result_repair_key;

DROP TABLE result_repair_key;
DROP TABLE weather_conditions;

0 comments on commit 6c6e175

Please sign in to comment.