Skip to content

Commit

Permalink
[feature](nereids)support join with joinRelation
Browse files Browse the repository at this point in the history
  • Loading branch information
starocean999 committed Feb 6, 2024
1 parent 2a2cced commit f231897
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ fromClause

relation
: relationPrimary joinRelation*
| LEFT_PAREN relationPrimary joinRelation* RIGHT_PAREN
;

joinRelation
Expand Down Expand Up @@ -450,6 +451,7 @@ relationPrimary
| tvfName=identifier LEFT_PAREN
(properties=propertyItemList)?
RIGHT_PAREN tableAlias #tableValuedFunction
| LEFT_PAREN relation (COMMA relation)* RIGHT_PAREN #relationList
;

materializedViewName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,11 @@ public LogicalPlan visitFromClause(FromClauseContext ctx) {
return ParserUtils.withOrigin(ctx, () -> withRelations(null, ctx.relation()));
}

@Override
public LogicalPlan visitRelationList(DorisParser.RelationListContext ctx) {
return ParserUtils.withOrigin(ctx, () -> withRelations(null, ctx.relation()));
}

/* ********************************************************************************************
* Table Identifier parsing
* ******************************************************************************************** */
Expand Down
3 changes: 3 additions & 0 deletions regression-test/data/nereids_p0/subquery/test_subquery.out
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ true 15 1992 3021 11011920 0.000 true 9999-12-12 2015-04-02T00:00 3.141592653 2
1 9
2 \N

-- !select_sub2 --
9

Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ suite("test_subquery") {
sql """insert into table_9_undef_undef values (0,3,"his",'g'),(1,8,'p','n'),(2,null,"get","got"),(3,3,'r','r'),(4,null,"or","get"),(5,0,'j',"yeah"),(6,null,'w','x'),(7,8,'q',"for"),(8,3,'p',"that");"""

qt_select_sub"""SELECT DISTINCT alias1.`pk` AS field1, alias2.`col_int_undef_signed` AS field2 FROM table_23_undef_undef AS alias1, table_20_undef_undef AS alias2 WHERE ( EXISTS ( SELECT DISTINCT SQ1_alias1.`col_varchar_10__undef_signed` AS SQ1_field1 FROM table_9_undef_undef AS SQ1_alias1 WHERE SQ1_alias1.`col_varchar_10__undef_signed` = alias1.`col_varchar_10__undef_signed` ) ) OR alias1.`col_varchar_1024__undef_signed` = "TmxRwcNZHC" AND ( alias1.`col_varchar_10__undef_signed` <> "rnZeukOcuM" AND alias2.`col_varchar_10__undef_signed` != "dbPAEpzstk" ) ORDER BY alias1.`pk`, field1, field2 LIMIT 2 OFFSET 7; """
qt_select_sub2 """select count(*) from table_9_undef_undef SQ1_alias1
LEFT JOIN ( table_20_undef_undef AS SQ1_alias2 RIGHT OUTER
JOIN table_23_undef_undef AS SQ1_alias3
ON SQ1_alias3.`pk` = SQ1_alias2.`pk` )
ON SQ1_alias1.`pk` = SQ1_alias2.`pk`;"""

sql """drop table if exists table_23_undef_undef"""
sql """drop table if exists table_20_undef_undef"""
sql """drop table if exists table_9_undef_undef"""
Expand Down

0 comments on commit f231897

Please sign in to comment.