proof_of_sql/sql/proof_plans/
dyn_proof_plan.rs

1use super::{
2    EmptyExec, FilterExec, GroupByExec, ProjectionExec, SliceExec, SortMergeJoinExec, TableExec,
3    UnionExec,
4};
5use crate::{
6    base::{
7        database::{ColumnField, ColumnRef, OwnedTable, Table, TableEvaluation, TableRef},
8        map::{IndexMap, IndexSet},
9        proof::ProofError,
10        scalar::Scalar,
11    },
12    sql::proof::{
13        FinalRoundBuilder, FirstRoundBuilder, ProofPlan, ProverEvaluate, VerificationBuilder,
14    },
15};
16use alloc::vec::Vec;
17use bumpalo::Bump;
18use serde::{Deserialize, Serialize};
19
20/// The query plan for proving a query
21#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
22#[enum_dispatch::enum_dispatch]
23pub enum DynProofPlan {
24    /// Source [`ProofPlan`] for (sub)queries without table source such as `SELECT "No table here" as msg;`
25    Empty(EmptyExec),
26    /// Source [`ProofPlan`] for (sub)queries with table source such as `SELECT col from tab;`
27    Table(TableExec),
28    /// Provable expressions for queries of the form
29    /// ```ignore
30    ///     SELECT <result_expr1>, ..., <result_exprN> FROM <table>
31    /// ```
32    Projection(ProjectionExec),
33    /// Provable expressions for queries of the form
34    /// ```ignore
35    ///     SELECT <group_by_expr1>, ..., <group_by_exprM>,
36    ///         SUM(<sum_expr1>.0) as <sum_expr1>.1, ..., SUM(<sum_exprN>.0) as <sum_exprN>.1,
37    ///         COUNT(*) as count_alias
38    ///     FROM <table>
39    ///     WHERE <where_clause>
40    ///     GROUP BY <group_by_expr1>, ..., <group_by_exprM>
41    /// ```
42    GroupBy(GroupByExec),
43    /// Provable expressions for queries of the form, where the result is sent in a dense form
44    /// ```ignore
45    ///     SELECT <result_expr1>, ..., <result_exprN> FROM <table> WHERE <where_clause>
46    /// ```
47    Filter(FilterExec),
48    /// `ProofPlan` for queries of the form
49    /// ```ignore
50    ///     <ProofPlan> LIMIT <fetch> [OFFSET <skip>]
51    /// ```
52    Slice(SliceExec),
53    /// `ProofPlan` for queries of the form
54    /// ```ignore
55    ///     <ProofPlan>
56    ///     UNION ALL
57    ///     <ProofPlan>
58    ///     ...
59    ///     UNION ALL
60    ///     <ProofPlan>
61    /// ```
62    Union(UnionExec),
63    /// `ProofPlan` for queries of the form
64    /// ```ignore
65    ///     <ProofPlan> INNER JOIN <ProofPlan>
66    ///     ON col1 = col2
67    /// ```
68    SortMergeJoin(SortMergeJoinExec),
69}