1+ //! This module defines the [`Memo`] trait, which defines shared behavior of all memo table that can
2+ //! be used for query optimization in the Cascades framework.
3+
14use crate :: OptimizerResult ;
25use thiserror:: Error ;
36
@@ -75,6 +78,11 @@ pub trait Memo {
7578 group_id : Self :: GroupId ,
7679 ) -> OptimizerResult < Vec < Self :: PhysicalExpressionId > > ;
7780
81+ /// Checks if a given logical expression is unique.
82+ ///
83+ /// TODO more docs.
84+ async fn is_unique_logical_expression ( & self ) -> OptimizerResult < bool > ;
85+
7886 /// Updates / replaces a group's best physical plan (winner). Optionally returns the previous
7987 /// winner's physical expression ID.
8088 ///
@@ -85,39 +93,45 @@ pub trait Memo {
8593 physical_expression_id : Self :: PhysicalExpressionId ,
8694 ) -> OptimizerResult < Option < Self :: PhysicalExpressionId > > ;
8795
88- /// Adds a logical expression to an existing group via its [`Self::GroupId`]. This function
96+ /// Adds a physical expression to an existing group via its [`Self::GroupId`]. This function
8997 /// assumes that insertion of this expression would not create any duplicates.
9098 ///
9199 /// The caller is required to pass in a slice of `GroupId` that represent the child groups of
92100 /// the input expression.
93101 ///
94- /// The caller is also required to set the `group_id` field of the input `logical_expression `
102+ /// The caller is also required to set the `group_id` field of the input `physical_expression `
95103 /// to be equal to `group_id`, otherwise this function will return a
96104 /// [`MemoError::InvalidExpression`] error.
97105 ///
98106 /// If the group does not exist, returns a [`MemoError::UnknownGroup`] error.
99- async fn add_logical_expression_to_group (
107+ ///
108+ /// FIXME: This needs to have a mechanism of reporting that a duplicate expression was found in
109+ /// another group.
110+ async fn add_physical_expression_to_group (
100111 & self ,
101112 group_id : Self :: GroupId ,
102- logical_expression : Self :: LogicalExpression ,
113+ physical_expression : Self :: PhysicalExpression ,
103114 children : & [ Self :: GroupId ] ,
104115 ) -> OptimizerResult < ( ) > ;
105116
106- /// Adds a physical expression to an existing group via its [`Self::GroupId`]. This function
117+ /// Adds a logical expression to an existing group via its [`Self::GroupId`]. This function
107118 /// assumes that insertion of this expression would not create any duplicates.
108119 ///
109120 /// The caller is required to pass in a slice of `GroupId` that represent the child groups of
110121 /// the input expression.
111122 ///
112- /// The caller is also required to set the `group_id` field of the input `physical_expression `
123+ /// The caller is also required to set the `group_id` field of the input `logical_expression `
113124 /// to be equal to `group_id`, otherwise this function will return a
114125 /// [`MemoError::InvalidExpression`] error.
115126 ///
116127 /// If the group does not exist, returns a [`MemoError::UnknownGroup`] error.
117- async fn add_physical_expression_to_group (
128+ ///
129+ /// FIXME: This needs to have a mechanism of reporting that a duplicate expression was found in
130+ /// another group.
131+ async fn add_logical_expression_to_group (
118132 & self ,
119133 group_id : Self :: GroupId ,
120- physical_expression : Self :: PhysicalExpression ,
134+ logical_expression : Self :: LogicalExpression ,
121135 children : & [ Self :: GroupId ] ,
122136 ) -> OptimizerResult < ( ) > ;
123137
0 commit comments