11use crate :: binder:: BindError ;
22use crate :: expression:: agg:: AggKind ;
3- use async_recursion:: async_recursion;
43use itertools:: Itertools ;
54use sqlparser:: ast:: {
65 BinaryOperator , Expr , Function , FunctionArg , FunctionArgExpr , Ident , UnaryOperator ,
@@ -10,35 +9,29 @@ use std::sync::Arc;
109
1110use super :: Binder ;
1211use crate :: expression:: ScalarExpression ;
13- use crate :: storage:: Storage ;
12+ use crate :: storage:: Transaction ;
1413use crate :: types:: value:: DataValue ;
1514use crate :: types:: LogicalType ;
1615
17- impl < S : Storage > Binder < S > {
18- #[ async_recursion]
19- pub ( crate ) async fn bind_expr ( & mut self , expr : & Expr ) -> Result < ScalarExpression , BindError > {
16+ impl < ' a , T : Transaction > Binder < ' a , T > {
17+ pub ( crate ) fn bind_expr ( & mut self , expr : & Expr ) -> Result < ScalarExpression , BindError > {
2018 match expr {
2119 Expr :: Identifier ( ident) => {
2220 self . bind_column_ref_from_identifiers ( slice:: from_ref ( ident) , None )
23- . await
24- }
25- Expr :: CompoundIdentifier ( idents) => {
26- self . bind_column_ref_from_identifiers ( idents, None ) . await
27- }
28- Expr :: BinaryOp { left, right, op } => {
29- self . bind_binary_op_internal ( left, right, op) . await
3021 }
22+ Expr :: CompoundIdentifier ( idents) => self . bind_column_ref_from_identifiers ( idents, None ) ,
23+ Expr :: BinaryOp { left, right, op } => self . bind_binary_op_internal ( left, right, op) ,
3124 Expr :: Value ( v) => Ok ( ScalarExpression :: Constant ( Arc :: new ( v. into ( ) ) ) ) ,
32- Expr :: Function ( func) => self . bind_agg_call ( func) . await ,
33- Expr :: Nested ( expr) => self . bind_expr ( expr) . await ,
34- Expr :: UnaryOp { expr, op } => self . bind_unary_op_internal ( expr, op) . await ,
25+ Expr :: Function ( func) => self . bind_agg_call ( func) ,
26+ Expr :: Nested ( expr) => self . bind_expr ( expr) ,
27+ Expr :: UnaryOp { expr, op } => self . bind_unary_op_internal ( expr, op) ,
3528 _ => {
3629 todo ! ( )
3730 }
3831 }
3932 }
4033
41- pub async fn bind_column_ref_from_identifiers (
34+ pub fn bind_column_ref_from_identifiers (
4235 & mut self ,
4336 idents : & [ Ident ] ,
4437 bind_table_name : Option < & String > ,
@@ -66,9 +59,8 @@ impl<S: Storage> Binder<S> {
6659 if let Some ( table) = table_name. or ( bind_table_name) {
6760 let table_catalog = self
6861 . context
69- . storage
62+ . transaction
7063 . table ( table)
71- . await
7264 . ok_or_else ( || BindError :: InvalidTable ( table. to_string ( ) ) ) ?;
7365
7466 let column_catalog = table_catalog
@@ -100,14 +92,14 @@ impl<S: Storage> Binder<S> {
10092 }
10193 }
10294
103- async fn bind_binary_op_internal (
95+ fn bind_binary_op_internal (
10496 & mut self ,
10597 left : & Expr ,
10698 right : & Expr ,
10799 op : & BinaryOperator ,
108100 ) -> Result < ScalarExpression , BindError > {
109- let left_expr = Box :: new ( self . bind_expr ( left) . await ?) ;
110- let right_expr = Box :: new ( self . bind_expr ( right) . await ?) ;
101+ let left_expr = Box :: new ( self . bind_expr ( left) ?) ;
102+ let right_expr = Box :: new ( self . bind_expr ( right) ?) ;
111103
112104 let ty = match op {
113105 BinaryOperator :: Plus
@@ -137,12 +129,12 @@ impl<S: Storage> Binder<S> {
137129 } )
138130 }
139131
140- async fn bind_unary_op_internal (
132+ fn bind_unary_op_internal (
141133 & mut self ,
142134 expr : & Expr ,
143135 op : & UnaryOperator ,
144136 ) -> Result < ScalarExpression , BindError > {
145- let expr = Box :: new ( self . bind_expr ( expr) . await ?) ;
137+ let expr = Box :: new ( self . bind_expr ( expr) ?) ;
146138 let ty = if let UnaryOperator :: Not = op {
147139 LogicalType :: Boolean
148140 } else {
@@ -156,7 +148,7 @@ impl<S: Storage> Binder<S> {
156148 } )
157149 }
158150
159- async fn bind_agg_call ( & mut self , func : & Function ) -> Result < ScalarExpression , BindError > {
151+ fn bind_agg_call ( & mut self , func : & Function ) -> Result < ScalarExpression , BindError > {
160152 let mut args = Vec :: with_capacity ( func. args . len ( ) ) ;
161153
162154 for arg in func. args . iter ( ) {
@@ -165,7 +157,7 @@ impl<S: Storage> Binder<S> {
165157 FunctionArg :: Unnamed ( arg) => arg,
166158 } ;
167159 match arg_expr {
168- FunctionArgExpr :: Expr ( expr) => args. push ( self . bind_expr ( expr) . await ?) ,
160+ FunctionArgExpr :: Expr ( expr) => args. push ( self . bind_expr ( expr) ?) ,
169161 FunctionArgExpr :: Wildcard => args. push ( Self :: wildcard_expr ( ) ) ,
170162 _ => todo ! ( ) ,
171163 }
0 commit comments