Skip to content

Commit

Permalink
feat: left join (#3576)
Browse files Browse the repository at this point in the history
* refactor: iterator & table handler

* refactor(runner): modulize runner.cc

runner.cc is too large, sepreate RunnerBuilder, RunnerContext, Runner and ClusterTask in
difference files

* feat(sql): support left join

* chore: refactor runner name & improve tests

* fix(runner): build cluster request join runner

For REQUESTJOIN(ANY1(T1), ANY2(T2)),
ANY1 may optimize T1, REQUESTJOIN, ANY2 may optimize T2, building
cluster task correctly
  • Loading branch information
aceforeverd authored Nov 15, 2023
1 parent 2fb650a commit 5d0d638
Show file tree
Hide file tree
Showing 39 changed files with 2,874 additions and 2,084 deletions.
71 changes: 67 additions & 4 deletions cases/plan/join_query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,83 @@ cases:
sql: SELECT t1.COL1, t1.COL2, t2.COL1, t2.COL2 FROM t1 full join t2 on t1.col1 = t2.col2;
mode: physical-plan-unsupport
- id: 2
mode: request-unsupport
desc: 简单SELECT LEFT JOIN
mode: runner-unsupport
sql: SELECT t1.COL1, t1.COL2, t2.COL1, t2.COL2 FROM t1 left join t2 on t1.col1 = t2.col2;
expect:
node_tree_str: |
+-node[kQuery]: kQuerySelect
+-distinct_opt: false
+-where_expr: null
+-group_expr_list: null
+-having_expr: null
+-order_expr_list: null
+-limit: null
+-select_list[list]:
| +-0:
| | +-node[kResTarget]
| | +-val:
| | | +-expr[column ref]
| | | +-relation_name: t1
| | | +-column_name: COL1
| | +-name: <nil>
| +-1:
| | +-node[kResTarget]
| | +-val:
| | | +-expr[column ref]
| | | +-relation_name: t1
| | | +-column_name: COL2
| | +-name: <nil>
| +-2:
| | +-node[kResTarget]
| | +-val:
| | | +-expr[column ref]
| | | +-relation_name: t2
| | | +-column_name: COL1
| | +-name: <nil>
| +-3:
| +-node[kResTarget]
| +-val:
| | +-expr[column ref]
| | +-relation_name: t2
| | +-column_name: COL2
| +-name: <nil>
+-tableref_list[list]:
| +-0:
| +-node[kTableRef]: kJoin
| +-join_type: LeftJoin
| +-left:
| | +-node[kTableRef]: kTable
| | +-table: t1
| | +-alias: <nil>
| +-right:
| +-node[kTableRef]: kTable
| +-table: t2
| +-alias: <nil>
| +-order_expressions: null
| +-on:
| +-expr[binary]
| +-=[list]:
| +-0:
| | +-expr[column ref]
| | +-relation_name: t1
| | +-column_name: col1
| +-1:
| +-expr[column ref]
| +-relation_name: t2
| +-column_name: col2
+-window_list: []
- id: 3
desc: 简单SELECT LAST JOIN
sql: SELECT t1.COL1, t1.COL2, t2.COL1, t2.COL2 FROM t1 last join t2 order by t2.col5 on t1.col1 = t2.col2;
- id: 4
desc: 简单SELECT RIGHT JOIN
sql: SELECT t1.COL1, t1.COL2, t2.COL1, t2.COL2 FROM t1 right join t2 on t1.col1 = t2.col2;
mode: runner-unsupport
mode: physical-plan-unsupport
- id: 5
desc: LeftJoin有不等式条件
sql: SELECT t1.col1 as t1_col1, t2.col2 as t2_col2 FROM t1 left join t2 on t1.col1 = t2.col2 and t2.col5 >= t1.col5;
mode: runner-unsupport
mode: request-unsupport
- id: 6
desc: LastJoin有不等式条件
sql: SELECT t1.col1 as t1_col1, t2.col2 as t2_col2 FROM t1 last join t2 order by t2.col5 on t1.col1 = t2.col2 and t2.col5 >= t1.col5;
Expand Down Expand Up @@ -162,4 +225,4 @@ cases:
col1 as id,
sum(col2) OVER w2 as w2_col2_sum FROM t1 WINDOW
w2 AS (PARTITION BY col1 ORDER BY col5 ROWS_RANGE BETWEEN 1d OPEN PRECEDING AND CURRENT ROW)
) as out1 ON out0.id = out1.id;
) as out1 ON out0.id = out1.id;
21 changes: 21 additions & 0 deletions cases/query/fail_query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,24 @@ cases:
SELECT 100 + 1s;
expect:
success: false
- id: 3
desc: unsupport join
inputs:
- name: t1
columns: ["c1 string","c2 int","c4 timestamp"]
indexs: ["index1:c1:c4"]
rows:
- ["aa",20,1000]
- ["bb",30,1000]
- name: t2
columns: ["c2 int","c4 timestamp"]
indexs: ["index1:c2:c4"]
rows:
- [20,3000]
- [20,2000]
sql: |
select t1.c1 as id, t2.* from t1 right join t2
on t1.c2 = t2.c2
expect:
success: false
msg: unsupport join type RightJoin
Loading

0 comments on commit 5d0d638

Please sign in to comment.