mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-07-08 17:35:00 +00:00
feat: Parse special keywords as functions (current_user, user, etc) (#561)
* feat: Parse special keywors as functions (current_user, user, etc) * explain special field
This commit is contained in:
parent
b6e36ad760
commit
54a29e872d
6 changed files with 111 additions and 17 deletions
|
@ -1400,6 +1400,7 @@ fn test_composite_value() {
|
|||
)))],
|
||||
over: None,
|
||||
distinct: false,
|
||||
special: false
|
||||
}))))
|
||||
}),
|
||||
select.projection[0]
|
||||
|
@ -1542,6 +1543,52 @@ fn parse_declare() {
|
|||
pg_and_generic().verified_stmt("DECLARE \"SQL_CUR0x7fa44801bc00\" BINARY INSENSITIVE SCROLL CURSOR WITH HOLD FOR SELECT * FROM table_name LIMIT 2222");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_current_functions() {
|
||||
let sql = "SELECT CURRENT_CATALOG, CURRENT_USER, SESSION_USER, USER";
|
||||
let select = pg_and_generic().verified_only_select(sql);
|
||||
assert_eq!(
|
||||
&Expr::Function(Function {
|
||||
name: ObjectName(vec![Ident::new("CURRENT_CATALOG")]),
|
||||
args: vec![],
|
||||
over: None,
|
||||
distinct: false,
|
||||
special: true,
|
||||
}),
|
||||
expr_from_projection(&select.projection[0])
|
||||
);
|
||||
assert_eq!(
|
||||
&Expr::Function(Function {
|
||||
name: ObjectName(vec![Ident::new("CURRENT_USER")]),
|
||||
args: vec![],
|
||||
over: None,
|
||||
distinct: false,
|
||||
special: true,
|
||||
}),
|
||||
expr_from_projection(&select.projection[1])
|
||||
);
|
||||
assert_eq!(
|
||||
&Expr::Function(Function {
|
||||
name: ObjectName(vec![Ident::new("SESSION_USER")]),
|
||||
args: vec![],
|
||||
over: None,
|
||||
distinct: false,
|
||||
special: true,
|
||||
}),
|
||||
expr_from_projection(&select.projection[2])
|
||||
);
|
||||
assert_eq!(
|
||||
&Expr::Function(Function {
|
||||
name: ObjectName(vec![Ident::new("USER")]),
|
||||
args: vec![],
|
||||
over: None,
|
||||
distinct: false,
|
||||
special: true,
|
||||
}),
|
||||
expr_from_projection(&select.projection[3])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_fetch() {
|
||||
pg_and_generic().verified_stmt("FETCH 2048 IN \"SQL_CUR0x7fa44801bc00\"");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue