From 943269641ea7513c1747fc6b2de10bcdfd037551 Mon Sep 17 00:00:00 2001 From: AlejandroLanaspa Date: Wed, 23 Oct 2024 13:05:40 +0200 Subject: [PATCH] fix: replacing avg for sum in queries --- crates/proof-of-sql/examples/movies/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/proof-of-sql/examples/movies/main.rs b/crates/proof-of-sql/examples/movies/main.rs index 5f4963798..67156aa64 100644 --- a/crates/proof-of-sql/examples/movies/main.rs +++ b/crates/proof-of-sql/examples/movies/main.rs @@ -118,9 +118,12 @@ fn main() { &verifier_setup, ); - // Query 3: Calculate the average duration of movies by genre + // Query 3: Calculate the total duration and count of movies by genre + // Note: We're using SUM and COUNT instead of AVG because the current version + // of the SQL parser doesn't support the AVG function. You can calculate the + // average by dividing total_duration by movie_count. prove_and_verify_query( - "SELECT genre, AVG(duration) AS avg_duration FROM movies GROUP BY genre ORDER BY avg_duration DESC", + "SELECT genre, SUM(duration) AS total_duration, COUNT(*) AS movie_count FROM movies GROUP BY genre ORDER BY total_duration DESC", &accessor, &prover_setup, &verifier_setup,