Skip to content

Commit b56f98b

Browse files
committed
WIP: Make test_materialize_topk working. Clean up agg_expr pretty printing in topk aggregate
1 parent ca3a37a commit b56f98b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2099,7 +2099,7 @@ pub mod tests {
20992099
"SELECT order_customer `customer`, SUM(order_amount) `amount`, \
21002100
MIN(order_amount) `min_amount`, MAX(order_amount) `max_amount` \
21012101
FROM s.orders \
2102-
GROUP BY 1 ORDER BY 3 DESC, 2 ASC LIMIT 10",
2102+
GROUP BY 1 ORDER BY 3 DESC NULLS LAST, 2 ASC LIMIT 10",
21032103
&indices,
21042104
);
21052105
let mut verbose = with_sort_by;
@@ -2108,7 +2108,7 @@ pub mod tests {
21082108
assert_eq!(
21092109
pretty_printers::pp_plan_ext(&plan, &verbose),
21102110
"Projection, [customer, amount, min_amount, max_amount]\
2111-
\n ClusterAggregateTopK, limit: 10, aggs: [SUM(#s.orders.order_amount), MIN(#s.orders.order_amount), MAX(#s.orders.order_amount)], sortBy: [3 desc null last, 2 null last]\
2111+
\n ClusterAggregateTopK, limit: 10, aggs: [sum(s.orders.order_amount), min(s.orders.order_amount), max(s.orders.order_amount)], sortBy: [3 desc null last, 2 null last]\
21122112
\n Scan s.orders, source: CubeTable(index: by_customer:3:[]:sort_on[order_customer]), fields: [order_customer, order_amount]"
21132113
);
21142114

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use datafusion::physical_plan::coalesce_partitions::CoalescePartitionsExec;
1515
use datafusion::physical_plan::filter::FilterExec;
1616
use datafusion::physical_plan::limit::{GlobalLimitExec, LocalLimitExec};
1717
use datafusion::physical_plan::{ExecutionPlan, InputOrderMode, PlanProperties};
18+
use datafusion::prelude::Expr;
1819
use itertools::{repeat_n, Itertools};
1920
use std::sync::Arc;
2021

@@ -255,7 +256,7 @@ pub fn pp_plan_ext(p: &LogicalPlan, opts: &PPOptions) -> String {
255256
{
256257
self.output += &format!("ClusterAggregateTopK, limit: {}", topk.limit);
257258
if self.opts.show_aggregations {
258-
self.output += &format!(", aggs: {:?}", topk.aggregate_expr)
259+
self.output += &format!(", aggs: {}", pp_exprs(&topk.aggregate_expr))
259260
}
260261
if self.opts.show_sort_by {
261262
self.output += &format!(
@@ -695,3 +696,7 @@ fn pp_row_range(r: &RowRange) -> String {
695696
};
696697
format!("[{},{})", s, e)
697698
}
699+
700+
fn pp_exprs(v: &Vec<Expr>) -> String {
701+
"[".to_owned() + &v.iter().map(|e: &Expr| format!("{}", e)).join(", ") + "]"
702+
}

0 commit comments

Comments
 (0)