mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 10:47:22 +00:00
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:
parent
3f5619446f
commit
a28bbcd74c
3 changed files with 31 additions and 17 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue