You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let sql = "SELECT person.id, ROW_NUMBER() OVER (PARTITION BY person.age ORDER BY person.id) as rn FROM person QUALIFY rn = 1";
4193
+
let plan = logical_plan(sql).unwrap();
4194
+
assert_snapshot!(
4195
+
plan,
4196
+
@r#"
4197
+
Projection: person.id, row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn
4198
+
Filter: row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW = Int64(1)
4199
+
WindowAggr: windowExpr=[[row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]
4200
+
TableScan: person
4201
+
"#
4202
+
);
4203
+
}
4204
+
4205
+
#[test]
4206
+
fntest_select_qualify_without_window_function(){
4207
+
let sql = "SELECT person.id FROM person QUALIFY person.id > 1";
4208
+
let err = logical_plan(sql).unwrap_err();
4209
+
assert_eq!(
4210
+
err.strip_backtrace(),
4211
+
"Error during planning: QUALIFY clause requires window functions in the SELECT list or QUALIFY clause"
4212
+
);
4213
+
}
4214
+
4215
+
#[test]
4216
+
fntest_select_qualify_complex_condition(){
4217
+
let sql = "SELECT person.id, person.age, ROW_NUMBER() OVER (PARTITION BY person.age ORDER BY person.id) as rn, RANK() OVER (ORDER BY person.salary) as rank FROM person QUALIFY rn <= 2 AND rank <= 5";
4218
+
let plan = logical_plan(sql).unwrap();
4219
+
assert_snapshot!(
4220
+
plan,
4221
+
@r#"
4222
+
Projection: person.id, person.age, row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rn, rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW AS rank
4223
+
Filter: row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(2) AND rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW <= Int64(5)
4224
+
WindowAggr: windowExpr=[[rank() ORDER BY [person.salary ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]
4225
+
WindowAggr: windowExpr=[[row_number() PARTITION BY [person.age] ORDER BY [person.id ASC NULLS LAST] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]
4226
+
TableScan: person
4227
+
"#
4228
+
);
4229
+
}
4230
+
4189
4231
#[rstest]
4190
4232
#[case::select_cluster_by_unsupported(
4191
4233
"SELECT customer_name, sum(order_total) as total_order_amount FROM orders CLUSTER BY customer_name",
0 commit comments