Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
Signed-off-by: YANGDB <[email protected]>
  • Loading branch information
YANG-DB committed Nov 5, 2024
1 parent 71b7497 commit ef1d890
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions docs/ppl-lang/ppl-expand-command.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@ Using `expand` command to flatten a field of type:


### Syntax
`flatten <field>`
`expand <field> [As alias]`

* field: to be expanded (exploded). The field must be of supported type.
* alias: Optional to be expanded as the name to be used instead of the original field name

### Test table

#### Schema
| col\_name | data\_type |
|-----------|----------------------------------------------|
| \_time | string |
| bridges | array\<struct\<length:bigint,name:string\>\> |
| city | string |
| country | string |

#### Data
| \_time | bridges | city | country |
|---------------------|----------------------------------------------|---------|----------------|
Expand All @@ -34,7 +37,7 @@ Using `expand` command to flatten a field of type:
### Example 1: expand struct
This example shows how to expand an array of struct field.
PPL query:
- `source=table | flatten bridges`
- `source=table | expand bridges as britishBridge | fields britishBridge`

| \_time | bridges | city | country | alt | lat | long |
|---------------------|----------------------------------------------|---------|---------------|-----|--------|--------|
Expand All @@ -47,12 +50,12 @@ PPL query:



### Example 2: flatten array
### Example 2: expand array

The example shows how to flatten an array of struct fields.
The example shows how to expand an array of struct fields.

PPL query:
- `source=table | flatten bridges`
- `source=table | expand bridges`

| \_time | city | coor | country | length | name |
|---------------------|---------|------------------------|---------------|--------|-------------------|
Expand All @@ -69,10 +72,10 @@ PPL query:
| 1990-09-13T12:00:00 | Warsaw | NULL | Poland | NULL | NULL |


### Example 3: flatten array and struct
This example shows how to flatten multiple fields.
### Example 3: expand array and struct
This example shows how to expand multiple fields.
PPL query:
- `source=table | flatten bridges | flatten coor`
- `source=table | expand bridges | expand coor`

| \_time | city | country | length | name | alt | lat | long |
|---------------------|---------|---------------|--------|-------------------|------|--------|--------|
Expand Down

0 comments on commit ef1d890

Please sign in to comment.