mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-23 15:34:09 +00:00
Add support of table function WITH ORDINALITY modifier for Postgre Parser (#1337)
This commit is contained in:
parent
285f492589
commit
9108bffc9a
16 changed files with 129 additions and 4 deletions
|
@ -3501,6 +3501,7 @@ fn parse_delimited_identifiers() {
|
|||
args,
|
||||
with_hints,
|
||||
version,
|
||||
with_ordinality: _,
|
||||
partitions: _,
|
||||
} => {
|
||||
assert_eq!(vec![Ident::with_quote('"', "a table")], name.0);
|
||||
|
@ -4054,7 +4055,8 @@ fn parse_join_constraint_unnest_alias() {
|
|||
Ident::new("a")
|
||||
])],
|
||||
with_offset: false,
|
||||
with_offset_alias: None
|
||||
with_offset_alias: None,
|
||||
with_ordinality: false,
|
||||
},
|
||||
join_operator: JoinOperator::Inner(JoinConstraint::On(Expr::BinaryOp {
|
||||
left: Box::new(Expr::Identifier("c1".into())),
|
||||
|
@ -4362,3 +4364,36 @@ fn parse_create_table_with_options() {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_table_function_with_ordinality() {
|
||||
let from = pg_and_generic()
|
||||
.verified_only_select("SELECT * FROM generate_series(1, 10) WITH ORDINALITY AS t")
|
||||
.from;
|
||||
assert_eq!(1, from.len());
|
||||
match from[0].relation {
|
||||
TableFactor::Table {
|
||||
ref name,
|
||||
with_ordinality: true,
|
||||
..
|
||||
} => {
|
||||
assert_eq!("generate_series", name.to_string().as_str());
|
||||
}
|
||||
_ => panic!("Expecting TableFactor::Table with ordinality"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_table_unnest_with_ordinality() {
|
||||
let from = pg_and_generic()
|
||||
.verified_only_select("SELECT * FROM UNNEST([10, 20, 30]) WITH ORDINALITY AS t")
|
||||
.from;
|
||||
assert_eq!(1, from.len());
|
||||
match from[0].relation {
|
||||
TableFactor::UNNEST {
|
||||
with_ordinality: true,
|
||||
..
|
||||
} => {}
|
||||
_ => panic!("Expecting TableFactor::UNNEST with ordinality"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue