Skip to content

Commit

Permalink
introduceAggCall::unchecked
Browse files Browse the repository at this point in the history
Signed-off-by: Runji Wang <[email protected]>
  • Loading branch information
wangrunji0408 committed Nov 24, 2023
1 parent fb80490 commit f59ec07
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/expr/impl/src/aggregate/general.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn last_value<T>(_: T, input: T) -> T {
input
}

#[aggregate("internal_last_seen_value(*) -> auto", state = "ref")]
#[aggregate("internal_last_seen_value(*) -> auto", state = "ref", internal)]
fn internal_last_seen_value<T>(state: T, input: T, retract: bool) -> T {
if retract {
state
Expand Down
14 changes: 3 additions & 11 deletions src/frontend/src/binder/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ use crate::catalog::system_catalog::rw_catalog::{
};
use crate::expr::{
AggCall, CorrelatedId, CorrelatedInputRef, Depth, Expr as _, ExprImpl, ExprType, FunctionCall,
InputRef, OrderBy,
InputRef,
};
use crate::utils::group_by::GroupBy;
use crate::utils::Condition;

#[derive(Debug, Clone)]
pub struct BoundSelect {
Expand Down Expand Up @@ -635,15 +634,8 @@ impl Binder {
.into();

// There could be multiple indexes on a table so aggregate the sizes of all indexes
let select_items: Vec<ExprImpl> = vec![AggCall::new(
AggKind::Sum0,
vec![sum],
false,
OrderBy::any(),
Condition::true_cond(),
vec![],
)?
.into()];
let select_items: Vec<ExprImpl> =
vec![AggCall::new_unchecked(AggKind::Sum, vec![sum], DataType::Int64)?.into()];

let indrelid_col = PG_INDEX_COLUMNS[1].1;
let indrelid_ref = self.bind_column(&[indrelid_col.into()])?;
Expand Down
17 changes: 17 additions & 0 deletions src/frontend/src/expr/agg_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,23 @@ impl AggCall {
})
}

/// Constructs an `AggCall` without type inference.
pub fn new_unchecked(
agg_kind: AggKind,
args: Vec<ExprImpl>,
return_type: DataType,
) -> Result<Self> {
Ok(AggCall {
agg_kind,
return_type,
args,
distinct: false,
order_by: OrderBy::any(),
filter: Condition::true_cond(),
direct_args: vec![],
})
}

pub fn decompose(
self,
) -> (
Expand Down

0 comments on commit f59ec07

Please sign in to comment.