|
| 1 | +========= |
| 2 | +appendpipe |
| 3 | +========= |
| 4 | + |
| 5 | +.. rubric:: Table of contents |
| 6 | + |
| 7 | +.. contents:: |
| 8 | + :local: |
| 9 | + :depth: 2 |
| 10 | + |
| 11 | + |
| 12 | +Description |
| 13 | +============ |
| 14 | +| Using ``appendpipe`` command to appends the result of the subpipeline to the search results. Unlike a subsearch, the subpipeline is not run first.The subpipeline is run when the search reaches the appendpipe command. |
| 15 | +The appendpipe command is used to append the output of transforming commands, such as chart, timechart, stats, and top. |
| 16 | +The command aligns columns with the same field names and types. For different column fields between the main search and sub-search, NULL values are filled in the respective rows. |
| 17 | + |
| 18 | +Version |
| 19 | +======= |
| 20 | +3.3.0 |
| 21 | + |
| 22 | +Syntax |
| 23 | +============ |
| 24 | +appendpipe [<subpipeline>] |
| 25 | + |
| 26 | +* subpipeline: mandatory. A list of commands that are applied to the search results from the commands that occur in the search before the ``appendpipe`` command. |
| 27 | + |
| 28 | +Example 1: Append rows from a total count to existing search result |
| 29 | +==================================================================================== |
| 30 | + |
| 31 | +This example appends rows from "total by gender" to "sum by gender, state" with merged column of same field name and type. |
| 32 | + |
| 33 | +PPL query:: |
| 34 | + |
| 35 | + os> source=accounts | stats sum(age) as part by gender, state | sort -sum | head 5 | appendpipe [ stats sum(part) as total by gender ]; |
| 36 | + fetched rows / total rows = 6/6 |
| 37 | + +------+--------+-------+-------+ |
| 38 | + | part | gender | state | total | |
| 39 | + |------+--------+-------+-------| |
| 40 | + | 36 | M | TN | null | |
| 41 | + | 33 | M | MD | null | |
| 42 | + | 32 | M | IL | null | |
| 43 | + | 28 | F | VA | null | |
| 44 | + | null | F | null | 28 | |
| 45 | + | null | M | null | 101 | |
| 46 | + +------+--------+-------+-------+ |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +Example 2: Append rows with merged column names |
| 51 | +=============================================================== |
| 52 | + |
| 53 | +This example appends rows from "count by gender" to "sum by gender, state". |
| 54 | + |
| 55 | +PPL query:: |
| 56 | + |
| 57 | + os> source=accounts | stats sum(age) as total by gender, state | sort -`sum(age)` | head 5 | appendpipe [ stats sum(total) as total by gender ]; |
| 58 | + fetched rows / total rows = 6/6 |
| 59 | + +----------+--------+-------+ |
| 60 | + | total | gender | state | |
| 61 | + |----------+--------+-------| |
| 62 | + | 36 | M | TN | |
| 63 | + | 33 | M | MD | |
| 64 | + | 32 | M | IL | |
| 65 | + | 28 | F | VA | |
| 66 | + | 28 | F | null | |
| 67 | + | 101 | M | null | |
| 68 | + +----------+--------+-------+ |
| 69 | + |
| 70 | +Example 3: Append rows with column type conflict |
| 71 | +============================================= |
| 72 | + |
| 73 | +This example shows how column type conflicts are handled when appending results. Same name columns with different types will generate two different columns in appended result. |
| 74 | + |
| 75 | +PPL query:: |
| 76 | + |
| 77 | + os> source=accounts | stats sum(age) as total by gender, state | sort -`sum(age)` | head 5 | appendpipe [ stats sum(total) as total by gender | eval state = 123 ]; |
| 78 | + fetched rows / total rows = 6/6 |
| 79 | + +------+--------+-------+--------+ |
| 80 | + | sum | gender | state | state0 | |
| 81 | + |------+--------+-------+--------| |
| 82 | + | 36 | M | TN | null | |
| 83 | + | 33 | M | MD | null | |
| 84 | + | 32 | M | IL | null | |
| 85 | + | 28 | F | VA | null | |
| 86 | + | 28 | F | null | 123 | |
| 87 | + | 101 | M | null | 123 | |
| 88 | + +------+--------+-------+--------+ |
| 89 | + |
0 commit comments