mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-10-17 09:17:14 +00:00
[mssql] Parse CROSS/OUTER APPLY
T-SQL (and Oracle) support non-standard syntax, which is similar in functionality to LATERAL joins in ANSI and PostgreSQL <https://blog.jooq.org/tag/lateral-derived-table/>: it allows to use the columns from the tables defined to the left of `APPLY` in the "derived tables" (subqueries) to the right of `APPLY`. Unlike ANSI LATERAL (but like Postgres' implementation), APPLY is also used with table-valued function calls. Despite them being similar, we represent "APPLY" joins with `JoinOperator`s of its own (`CrossApply` and `OuterApply`). Doing otherwise seemed like it would cause unnecessary confusion, as those interested in dialect-specific parsing would probably not expect APPLY being parsed as LATERAL, and those wanting to forbid non-standard SQL would not be helped by this either. This also renames existing JoinOperator::Cross -> CrossJoin to avoid confusion with CrossApply.
This commit is contained in:
parent
0f6bf15258
commit
4294581ded
5 changed files with 44 additions and 10 deletions
|
@ -1560,7 +1560,7 @@ fn parse_cross_join() {
|
|||
args: vec![],
|
||||
with_hints: vec![],
|
||||
},
|
||||
join_operator: JoinOperator::Cross
|
||||
join_operator: JoinOperator::CrossJoin
|
||||
},
|
||||
only(only(select.from).joins),
|
||||
);
|
||||
|
@ -1804,7 +1804,7 @@ fn parse_join_syntax_variants() {
|
|||
|
||||
let res = parse_sql_statements("SELECT * FROM a OUTER JOIN b ON 1");
|
||||
assert_eq!(
|
||||
ParserError::ParserError("Expected LEFT, RIGHT, or FULL, found: OUTER".to_string()),
|
||||
ParserError::ParserError("Expected APPLY, found: JOIN".to_string()),
|
||||
res.unwrap_err()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue