Allow array to be used as a function name again (#432)

* Allow `array` to be used as a function

* clarify code, add docstrings

* fix docs

* cleanup

* fmt
This commit is contained in:
Andrew Lamb 2022-03-08 13:25:48 -05:00 committed by GitHub
parent 3f5619446f
commit a28bbcd74c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 17 deletions

View file

@ -2246,19 +2246,24 @@ fn parse_bad_constraint() {
#[test]
fn parse_scalar_function_in_projection() {
let sql = "SELECT sqrt(id) FROM foo";
let select = verified_only_select(sql);
assert_eq!(
&Expr::Function(Function {
name: ObjectName(vec![Ident::new("sqrt")]),
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(
Expr::Identifier(Ident::new("id"))
))],
over: None,
distinct: false,
}),
expr_from_projection(only(&select.projection))
);
let names = vec!["sqrt", "array", "foo"];
for function_name in names {
// like SELECT sqrt(id) FROM foo
let sql = dbg!(format!("SELECT {}(id) FROM foo", function_name));
let select = verified_only_select(&sql);
assert_eq!(
&Expr::Function(Function {
name: ObjectName(vec![Ident::new(function_name)]),
args: vec![FunctionArg::Unnamed(FunctionArgExpr::Expr(
Expr::Identifier(Ident::new("id"))
))],
over: None,
distinct: false,
}),
expr_from_projection(only(&select.projection))
);
}
}
fn run_explain_analyze(query: &str, expected_verbose: bool, expected_analyze: bool) {