Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
kwannoel committed Jul 24, 2024
1 parent 6473983 commit 2d76cae
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/expr/core/src/aggregate/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ pub mod agg_kinds {
| PbAggKind::StddevSamp
| PbAggKind::VarPop
| PbAggKind::VarSamp
| PbAggKind::Grouping,
| PbAggKind::Grouping
// ApproxPercentile always uses custom agg executors,
// rather than an aggregation operator
| PbAggKind::ApproxPercentile
Expand Down Expand Up @@ -446,13 +446,14 @@ pub mod agg_kinds {
macro_rules! ordered_set {
() => {
AggKind::Builtin(
PbAggKind::PercentileCont | PbAggKind::PercentileDisc | PbAggKind::Mode | PbAggKind::ApproxPercentile
PbAggKind::PercentileCont
| PbAggKind::PercentileDisc
| PbAggKind::Mode
| PbAggKind::ApproxPercentile,
)
};
}
pub use ordered_set;

use crate::aggregate::{AggKind, PbAggKind};
}

impl AggKind {
Expand Down
8 changes: 6 additions & 2 deletions src/frontend/src/binder/expr/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,11 @@ impl Binder {
}
}
(AggKind::Builtin(PbAggKind::Mode), [], [_arg]) => {}
(AggKind::Builtin(PbAggKind::ApproxPercentile), [percentile, relative_error], [_percentile_col]) => {
(
AggKind::Builtin(PbAggKind::ApproxPercentile),
[percentile, relative_error],
[_percentile_col],
) => {
Self::decimal_to_float64(percentile, &kind)?;
Self::decimal_to_float64(relative_error, &kind)?;
}
Expand Down Expand Up @@ -579,7 +583,7 @@ impl Binder {
if matches!(
kind,
AggKind::Builtin(PbAggKind::ApproxCountDistinct)
| AggKind::Builtin(PbAggKind::ApproxPercentile)
| AggKind::Builtin(PbAggKind::ApproxPercentile)
) {
return Err(ErrorCode::InvalidInputSyntax(format!(
"DISTINCT is not allowed for approximate aggregation `{}`",
Expand Down
1 change: 0 additions & 1 deletion src/frontend/src/expr/agg_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ impl std::fmt::Debug for AggCall {
.field("distinct", &self.distinct)
.field("order_by", &self.order_by)
.field("direct_args", &self.direct_args)
.field("user_defined", &self.user_defined.is_some())
.finish()
} else {
let mut builder = f.debug_tuple(&format!("{}", self.agg_kind));
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/src/optimizer/plan_node/generic/agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ impl<PlanRef: GenericPlanRef> Agg<PlanRef> {
let agg_kind_ok = !matches!(call.agg_kind, agg_kinds::simply_cannot_two_phase!());
let order_ok = matches!(
call.agg_kind,
agg_kinds::result_unaffected_by_order_by!() | AggKind::ApproxPercentile
agg_kinds::result_unaffected_by_order_by!()
| AggKind::Builtin(PbAggKind::ApproxPercentile)
) || call.order_by.is_empty();
let distinct_ok =
matches!(call.agg_kind, agg_kinds::result_unaffected_by_distinct!())
Expand Down Expand Up @@ -135,7 +136,7 @@ impl<PlanRef: GenericPlanRef> Agg<PlanRef> {
self.agg_calls.iter().all(|c| {
matches!(c.agg_kind, agg_kinds::single_value_state!())
|| (matches!(c.agg_kind, agg_kinds::single_value_state_iff_in_append_only!() if stream_input_append_only))
|| (matches!(c.agg_kind, AggKind::ApproxPercentile))
|| (matches!(c.agg_kind, AggKind::Builtin(PbAggKind::ApproxPercentile)))
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/optimizer/plan_node/logical_agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ impl LogicalAgg {
let mut approx_percentile_col_mapping = Vec::with_capacity(estimated_len);
let mut non_approx_percentile_col_mapping = Vec::with_capacity(estimated_len);
for (output_idx, agg_call) in self.agg_calls().iter().enumerate() {
if agg_call.agg_kind == AggKind::ApproxPercentile {
if agg_call.agg_kind == AggKind::Builtin(PbAggKind::ApproxPercentile) {
approx_percentile_agg_calls.push(agg_call.clone());
approx_percentile_col_mapping.push(Some(output_idx));
} else {
Expand Down Expand Up @@ -643,7 +643,7 @@ impl LogicalAggBuilder {
_ => unreachable!(),
}
}
AggKind::ApproxPercentile => {
AggKind::Builtin(PbAggKind::ApproxPercentile) => {
if agg_call.order_by.sort_exprs[0].order_type == OrderType::descending() {
// Rewrite DESC into 1.0-percentile for approx_percentile.
let prev_percentile = agg_call.direct_args[0].clone();
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/optimizer/rule/distinct_agg_rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ impl Rule for DistinctAggRule {
let agg_kind_ok = !matches!(c.agg_kind, agg_kinds::simply_cannot_two_phase!());
let order_ok = matches!(
c.agg_kind,
agg_kinds::result_unaffected_by_order_by!() | AggKind::ApproxPercentile
agg_kinds::result_unaffected_by_order_by!()
| AggKind::Builtin(PbAggKind::ApproxPercentile)
) || c.order_by.is_empty();
agg_kind_ok && order_ok
}) {
Expand Down

0 comments on commit 2d76cae

Please sign in to comment.