Skip to content

Commit

Permalink
[Improve][SQL-Transform] update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
liunaijie committed Mar 12, 2024
1 parent 0331a65 commit 19019ee
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/en/transform-v2/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ select
c_row.c_inner_row.c_map_2.some_key.inner_map_key
```

The map must be the latest struct, can query the nesting map.
The map must be the latest struct, can't query the nesting map.

## Job Config Example

Expand Down
58 changes: 58 additions & 0 deletions docs/zh/transform-v2/sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ SQL 转换使用内存中的 SQL 引擎,我们可以通过 SQL 函数和 SQL

查询 SQL,它是一个简单的 SQL,支持基本的函数和条件过滤操作。但是,复杂的 SQL 尚不支持,包括:多源表/行连接和聚合操作等。

查询表达式可以是`select [table_name.]column_a`,这时会去查询列为`column_a`的列,`table_name`为可选项
也可以是`select c_row.c_inner_row.column_b`,这时会去查询列`c_row`下的`c_inner_row``column_b`**嵌套结构查询中,不能存在`table_name`**

## 示例

源端数据读取的表格如下:
Expand Down Expand Up @@ -56,6 +59,61 @@ transform {
| 3 | Kin Dom_ | 25 |
| 4 | Joy Dom_ | 23 |

### 嵌套结构查询

例如你的上游数据结构是这样:

```hacon
source {
FakeSource {
result_table_name = "fake"
row.num = 100
string.template = ["innerQuery"]
schema = {
fields {
name = "string"
c_date = "date"
c_row = {
c_inner_row = {
c_inner_int = "int"
c_inner_string = "string"
c_inner_timestamp = "timestamp"
c_map_1 = "map<string, string>"
c_map_2 = "map<string, map<string,string>>"
}
c_string = "string"
}
}
}
}
}
```

那么下列所有的查询表达式都是有效的

```sql
select
name,
c_date,
c_row,
c_row.c_inner_row,
c_row.c_string,
c_row.c_inner_row.c_inner_int,
c_row.c_inner_row.c_inner_string,
c_row.c_inner_row.c_inner_timestamp,
c_row.c_inner_row.c_map_1,
c_row.c_inner_row.c_map_1.some_key
```

但是这个查询语句是无效的

```sql
select
c_row.c_inner_row.c_map_2.some_key.inner_map_key
```

当查询map结构时,map结构应该为最后一个数据结构,不能查询嵌套map

## 作业配置示例

```
Expand Down

0 comments on commit 19019ee

Please sign in to comment.