Skip to content

Commit 626bf05

Browse files
committed
WIP: AggregateTopKExec pretty printing
1 parent d824b13 commit 626bf05

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

rust/cubestore/cubestore/src/queryplanner/planning.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,11 +2044,11 @@ pub mod tests {
20442044
&indices,
20452045
);
20462046
let plan = choose_index(plan, &indices).await.unwrap().0;
2047+
20472048
assert_eq!(
20482049
pretty_printers::pp_plan(&plan),
2049-
"Projection, [s.Orders.order_customer, SUM(s.Orders.order_amount)]\
2050-
\n ClusterAggregateTopK, limit: 10\
2051-
\n Scan s.Orders, source: CubeTable(index: by_customer:3:[]:sort_on[order_customer]), fields: [order_customer, order_amount]"
2050+
"ClusterAggregateTopK, limit: 10\
2051+
\n Scan s.orders, source: CubeTable(index: by_customer:3:[]:sort_on[order_customer]), fields: [order_customer, order_amount]"
20522052
);
20532053

20542054
// Projections should be handled properly.
@@ -2062,7 +2062,7 @@ pub mod tests {
20622062
pretty_printers::pp_plan(&plan),
20632063
"Projection, [customer, amount]\
20642064
\n ClusterAggregateTopK, limit: 10\
2065-
\n Scan s.Orders, source: CubeTable(index: by_customer:3:[]:sort_on[order_customer]), fields: [order_customer, order_amount]"
2065+
\n Scan s.orders, source: CubeTable(index: by_customer:3:[]:sort_on[order_customer]), fields: [order_customer, order_amount]"
20662066
);
20672067

20682068
let plan = initial_plan(
@@ -2077,7 +2077,7 @@ pub mod tests {
20772077
pretty_printers::pp_plan_ext(&plan, &with_sort_by),
20782078
"Projection, [amount, customer]\
20792079
\n ClusterAggregateTopK, limit: 10, sortBy: [2 desc null last]\
2080-
\n Scan s.Orders, source: CubeTable(index: by_customer:3:[]:sort_on[order_customer]), fields: [order_customer, order_amount]"
2080+
\n Scan s.orders, source: CubeTable(index: by_customer:3:[]:sort_on[order_customer]), fields: [order_customer, order_amount]"
20812081
);
20822082

20832083
// Ascending order is also ok.

rust/cubestore/cubestore/src/queryplanner/pretty_printers.rs

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::queryplanner::query_executor::{
3030
use crate::queryplanner::rolling::RollingWindowAggregate;
3131
use crate::queryplanner::serialized_plan::{IndexSnapshot, RowRange};
3232
use crate::queryplanner::tail_limit::TailLimitExec;
33-
use crate::queryplanner::topk::ClusterAggregateTopK;
33+
use crate::queryplanner::topk::{AggregateTopKExec, ClusterAggregateTopK};
3434
use crate::queryplanner::topk::SortColumn;
3535
use crate::queryplanner::trace_data_loaded::TraceDataLoadedExec;
3636
use crate::queryplanner::{CubeTableLogical, InfoSchemaTableProvider};
@@ -379,7 +379,6 @@ fn pp_source(t: Arc<dyn TableProvider>) -> String {
379379
}
380380
}
381381

382-
// TODO upgrade DF: No pub
383382
pub fn pp_sort_columns(first_agg: usize, cs: &[SortColumn]) -> String {
384383
format!(
385384
"[{}]",
@@ -536,23 +535,22 @@ fn pp_phys_plan_indented(p: &dyn ExecutionPlan, indent: usize, o: &PPOptions, ou
536535
})
537536
.join(", ")
538537
);
539-
// TODO upgrade DF <-
540-
// } else if let Some(topk) = a.downcast_ref::<AggregateTopKExec>() {
541-
// *out += &format!("AggregateTopK, limit: {:?}", topk.limit);
542-
// if o.show_aggregations {
543-
// *out += &format!(", aggs: {:?}", topk.agg_expr);
544-
// }
545-
// if o.show_sort_by {
546-
// *out += &format!(
547-
// ", sortBy: {}",
548-
// pp_sort_columns(topk.key_len, &topk.order_by)
549-
// );
550-
// }
551-
// if o.show_filters {
552-
// if let Some(having) = &topk.having {
553-
// *out += &format!(", having: {}", having);
554-
// }
555-
// }
538+
} else if let Some(topk) = a.downcast_ref::<AggregateTopKExec>() {
539+
*out += &format!("AggregateTopK, limit: {:?}", topk.limit);
540+
if o.show_aggregations {
541+
*out += &format!(", aggs: {:?}", topk.agg_expr);
542+
}
543+
if o.show_sort_by {
544+
*out += &format!(
545+
", sortBy: {}",
546+
pp_sort_columns(topk.key_len, &topk.order_by)
547+
);
548+
}
549+
if o.show_filters {
550+
if let Some(having) = &topk.having {
551+
*out += &format!(", having: {}", having);
552+
}
553+
}
556554
} else if let Some(_) = a.downcast_ref::<PanicWorkerExec>() {
557555
*out += "PanicWorker";
558556
} else if let Some(_) = a.downcast_ref::<WorkerExec>() {

0 commit comments

Comments
 (0)