Skip to content

Commit 7fcc454

Browse files
committed
feat: impl dql count(*)
1 parent 3d669b2 commit 7fcc454

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/binder/expr.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use super::Binder;
1010
use crate::expression::ScalarExpression;
1111
use crate::storage::Storage;
1212
use crate::types::LogicalType;
13+
use crate::types::value::DataValue;
1314

1415
impl<S: Storage> Binder<S> {
1516
#[async_recursion]
@@ -135,6 +136,7 @@ impl<S: Storage> Binder<S> {
135136
};
136137
match arg_expr {
137138
FunctionArgExpr::Expr(expr) => args.push(self.bind_expr(expr).await?),
139+
FunctionArgExpr::Wildcard => args.push(Self::wildcard_expr()),
138140
_ => todo!()
139141
}
140142
}
@@ -174,4 +176,8 @@ impl<S: Storage> Binder<S> {
174176
_ => todo!(),
175177
})
176178
}
179+
180+
fn wildcard_expr() -> ScalarExpression {
181+
ScalarExpression::Constant(Arc::new(DataValue::Utf8(Some("*".to_string()))))
182+
}
177183
}

src/db.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ mod test {
227227
let tuples_count_agg = kipsql.run("select count(d) from t2").await?;
228228
println!("{}", create_table(&tuples_count_agg));
229229

230+
println!("count wildcard agg:");
231+
let tuples_count_wildcard_agg = kipsql.run("select count(*) from t2").await?;
232+
println!("{}", create_table(&tuples_count_wildcard_agg));
233+
230234
println!("count distinct agg:");
231235
let tuples_count_distinct_agg = kipsql.run("select count(distinct d) from t2").await?;
232236
println!("{}", create_table(&tuples_count_distinct_agg));

0 commit comments

Comments
 (0)