Skip to content

Commit

Permalink
[MySQL] Modify JOIN clause to support unstructured joins (antlr#3668)
Browse files Browse the repository at this point in the history
  • Loading branch information
ani-sha authored Aug 17, 2023
1 parent e9fa5da commit d5c0376
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 8 additions & 11 deletions sql/mysql/Positive-Technologies/MySqlParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -1043,20 +1043,17 @@ indexHintType
;

joinPart
: (INNER | CROSS)? JOIN LATERAL? tableSourceItem
(
ON expression
| USING '(' uidList ')'
)? #innerJoin
| STRAIGHT_JOIN tableSourceItem (ON expression)? #straightJoin
| (LEFT | RIGHT) OUTER? JOIN LATERAL? tableSourceItem
(
ON expression
| USING '(' uidList ')'
) #outerJoin
: (INNER | CROSS)? JOIN LATERAL? tableSourceItem joinSpec* #innerJoin
| STRAIGHT_JOIN tableSourceItem (ON expression)* #straightJoin
| (LEFT | RIGHT) OUTER? JOIN LATERAL? tableSourceItem joinSpec* #outerJoin
| NATURAL ((LEFT | RIGHT) OUTER?)? JOIN tableSourceItem #naturalJoin
;

joinSpec
: (ON expression)
| USING '(' uidList ')'
;

// Select Statement's Details

queryExpression
Expand Down
2 changes: 2 additions & 0 deletions sql/mysql/Positive-Technologies/examples/dml_select.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ order by ship_power.ship_name;
select * from t1 inner join (t1 as tt1, t2 as tt2) on t1.col1 = tt1.col1;
select * from (t1 as tt1, t2 as tt2) inner join t1 on t1.col1 = tt1.col1;
select * from t1 as tt1, t2 as tt2 inner join t1 on true;
SELECT * FROM test_table_1 t1 LEFT JOIN test_table_2 t2 JOIN test_table_3 t3 ON t3.id=t2.id ON t1.id=t2.id;
SELECT * FROM TABLE1 T1 STRAIGHT_JOIN TABLE2 T2 STRAIGHT_JOIN TABLE3 T3 ON T3.ID=T2.ID ON T1.ID=T2.ID;
#end
#begin
-- where_condition test
Expand Down

0 comments on commit d5c0376

Please sign in to comment.