Skip to content

Commit

Permalink
fix partition by print
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiayu Liu committed Jun 5, 2021
1 parent ecc10dc commit b6c6023
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 35 deletions.
6 changes: 1 addition & 5 deletions datafusion/src/logical_plan/plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,11 +687,7 @@ impl LogicalPlan {
LogicalPlan::Window {
ref window_expr, ..
} => {
write!(
f,
"WindowAggr: windowExpr=[{:?}] partitionBy=[]",
window_expr
)
write!(f, "WindowAggr: windowExpr=[{:?}]", window_expr)
}
LogicalPlan::Aggregate {
ref group_expr,
Expand Down
60 changes: 30 additions & 30 deletions datafusion/src/sql/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,7 @@ mod tests {
let sql = "SELECT order_id, MAX(order_id) OVER () from orders";
let expected = "\
Projection: #order_id, #MAX(order_id)\
\n WindowAggr: windowExpr=[[MAX(#order_id)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#order_id)]]\
\n TableScan: orders projection=None";
quick_test(sql, expected);
}
Expand All @@ -2748,7 +2748,7 @@ mod tests {
let sql = "SELECT order_id oid, MAX(order_id) OVER () max_oid from orders";
let expected = "\
Projection: #order_id AS oid, #MAX(order_id) AS max_oid\
\n WindowAggr: windowExpr=[[MAX(#order_id)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#order_id)]]\
\n TableScan: orders projection=None";
quick_test(sql, expected);
}
Expand All @@ -2758,7 +2758,7 @@ mod tests {
let sql = "SELECT order_id, MAX(qty * 1.1) OVER () from orders";
let expected = "\
Projection: #order_id, #MAX(qty Multiply Float64(1.1))\
\n WindowAggr: windowExpr=[[MAX(#qty Multiply Float64(1.1))]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty Multiply Float64(1.1))]]\
\n TableScan: orders projection=None";
quick_test(sql, expected);
}
Expand All @@ -2769,7 +2769,7 @@ mod tests {
"SELECT order_id, MAX(qty) OVER (), min(qty) over (), aVg(qty) OVER () from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty), #AVG(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty), MIN(#qty), AVG(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty), MIN(#qty), AVG(#qty)]]\
\n TableScan: orders projection=None";
quick_test(sql, expected);
}
Expand All @@ -2788,7 +2788,7 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (PARTITION BY order_id) from orders";
let expected = "\
Projection: #order_id, #MAX(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2811,9 +2811,9 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (ORDER BY order_id), MIN(qty) OVER (ORDER BY order_id DESC) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id DESC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2824,9 +2824,9 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (ORDER BY order_id RANGE BETWEEN 3 PRECEDING and 3 FOLLOWING), MIN(qty) OVER (ORDER BY order_id DESC) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id DESC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2837,9 +2837,9 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (ORDER BY order_id RANGE 3 PRECEDING), MIN(qty) OVER (ORDER BY order_id DESC) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id DESC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2850,9 +2850,9 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (ORDER BY order_id GROUPS 3 PRECEDING), MIN(qty) OVER (ORDER BY order_id DESC) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id DESC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2875,9 +2875,9 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (ORDER BY order_id), MIN(qty) OVER (ORDER BY (order_id + 1)) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id Plus Int64(1) ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2901,10 +2901,10 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (ORDER BY qty, order_id), SUM(qty) OVER (), MIN(qty) OVER (ORDER BY order_id, qty) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #SUM(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[SUM(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[SUM(#qty)]]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #qty ASC NULLS FIRST, #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2928,10 +2928,10 @@ mod tests {
let sql = "SELECT order_id, MAX(qty) OVER (ORDER BY order_id), SUM(qty) OVER (), MIN(qty) OVER (ORDER BY order_id, qty) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #SUM(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[SUM(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[SUM(#qty)]]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand Down Expand Up @@ -2959,10 +2959,10 @@ mod tests {
let expected = "\
Sort: #order_id ASC NULLS FIRST\
\n Projection: #order_id, #MAX(qty), #SUM(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[SUM(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[SUM(#qty)]]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #qty ASC NULLS FIRST, #order_id ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -2983,7 +2983,7 @@ mod tests {
"SELECT order_id, MAX(qty) OVER (PARTITION BY order_id ORDER BY qty) from orders";
let expected = "\
Projection: #order_id, #MAX(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -3004,7 +3004,7 @@ mod tests {
"SELECT order_id, MAX(qty) OVER (PARTITION BY order_id, qty ORDER BY qty) from orders";
let expected = "\
Projection: #order_id, #MAX(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -3028,9 +3028,9 @@ mod tests {
"SELECT order_id, MAX(qty) OVER (PARTITION BY order_id, qty ORDER BY qty), MIN(qty) OVER (PARTITION BY qty ORDER BY order_id) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #qty ASC NULLS FIRST, #order_id ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand All @@ -3053,9 +3053,9 @@ mod tests {
"SELECT order_id, MAX(qty) OVER (PARTITION BY order_id ORDER BY qty), MIN(qty) OVER (PARTITION BY order_id, qty ORDER BY price) from orders";
let expected = "\
Projection: #order_id, #MAX(qty), #MIN(qty)\
\n WindowAggr: windowExpr=[[MAX(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MAX(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST\
\n WindowAggr: windowExpr=[[MIN(#qty)]] partitionBy=[]\
\n WindowAggr: windowExpr=[[MIN(#qty)]]\
\n Sort: #order_id ASC NULLS FIRST, #qty ASC NULLS FIRST, #price ASC NULLS FIRST\
\n TableScan: orders projection=None";
quick_test(sql, expected);
Expand Down

0 comments on commit b6c6023

Please sign in to comment.