-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(sql): update sql supports (#3672)
- add set operation
- Loading branch information
1 parent
0c2592d
commit fa91a98
Showing
7 changed files
with
100 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# SET Operation | ||
|
||
|
||
|
||
SET 操作将两个或者更多相同输出 schema 的 query 语句按特定的规则整合成一个结果输出. 共有三种 Set 操作符: `UNION`, `INTERSECT`, `EXCEPT`, OpenMLDB 目前仅支持 `UNION`. | ||
|
||
|
||
|
||
## Syntax | ||
|
||
```yacc | ||
set_operation: | ||
query set_operator query | ||
set_operator: | ||
UNION { ALL | DISTINCT } | ||
``` | ||
|
||
注意 | ||
|
||
- `ALL/DISTINCT` 是必填, 不支持单独 UNION 的写法 | ||
- 同一层 Set Operation 里, 多个 UNION 操作必须都是 UNION ALL 或者 UNION DISTINCT. 可以利用子查询将不同 DISTINCT 属性的 query 串联起来 | ||
- 这里的 UNION 语法不同于 [WINDOW clause](./WINDOW_CLAUSE.md) 中的 WINDOW UNION 语法 | ||
|
||
## 边界说明 | ||
|
||
| SELECT语句元素 | 离线模式 | 在线预览模式 | 在线请求模式 | 说明 | | ||
| :------------- | --------- | ------------ | ------------ | :--- | | ||
| SET Operation | **``✓``** | **``✓``** | **``✓``** | | | ||
|
||
- 在线模式下只支持 UNION ALL, 离线模式支持 UNION ALL 和 UNION DISTINCT | ||
|
||
|
||
|
||
## Example | ||
|
||
```sql | ||
SELECT * FROM t1 | ||
UNION ALL | ||
SELECT * FROM t2 | ||
UNION ALL | ||
SELECT * FROM t3 | ||
|
||
-- differnt DISTINCT field | ||
SELECT * FROM t1 | ||
UNION ALL | ||
( | ||
SELECT * FROM t2 | ||
UNION DISTINCT | ||
SELECT * FROM t3 | ||
) | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
SELECT_STATEMENT | ||
JOIN_CLAUSE | ||
SET_OPERATION | ||
WHERE_CLAUSE | ||
GROUP_BY_CLAUSE | ||
HAVING_CLAUSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.