Skip to content

Commit

Permalink
fix(binder): do not allow correlated input ref in order by (risingwav…
Browse files Browse the repository at this point in the history
  • Loading branch information
xxchan authored Jun 20, 2022
1 parent 263d770 commit 1e190dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/frontend/src/binder/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ impl Binder {
}
},
expr => {
extra_order_exprs.push(self.bind_expr(expr)?);
let order_expr = self.bind_expr(expr.clone())?;
if order_expr.has_correlated_input_ref() {
return Err(ErrorCode::BindError(format!("ORDER BY expression \"{}\" has correlated input reference", expr)).into());
}
extra_order_exprs.push(order_expr);
visible_output_num + extra_order_exprs.len() - 1
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/frontend/test_runner/tests/testdata/subquery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,7 @@
create table t (v1 bigint, v2 double precision);
select * from (select * from t) as tt(a, b, c) join t on a=v1;
binder_error: 'Bind error: table "tt" has less columns available but more aliases specified'
- sql: |
create table t(x int);
select * from t, (select * from t as t2 order by t.x desc) as t3;
binder_error: 'Bind error: ORDER BY expression "t.x" has correlated input reference'

0 comments on commit 1e190dd

Please sign in to comment.