Skip to content

[FEATURE] implment transpose command as in the roadmap #4786

@asifabashar

Description

@asifabashar

The transpose command outputs the requested number of search rows as columns, effectively transposing each result row into a corresponding column of field values. (Part of roadmap [#4287])


Syntax

transpose [int] [column_name=<string>] 

Required Arguments: None.
Optional Arguments:

column_name
Syntax: column_name=<string>

Description: The name of the first column to use when transposing rows. This column holds the field names.

Default: column

int
Syntax: <int>

Description: Limit the number of rows to transpose. 

Default: 5

Usage Notes: 

When you use the transpose command, the field names in the output depend on the arguments provided.
By default, the field names are:
column, row 1, row 2, ...

Examples
1. Transpose the results of a stats command

os> source=accounts | stats sum(age) by gender, state
| sum(age) | gender | state |
|-----------|---------|--------|
| 36        | M       | TN     |
| 33        | M       | MD     |
| 32        | M       | IL     |
| 28        | F       | VA     |


When you add the transpose command to the end of the search, the results look something like this:
os> source=accounts | stats sum(age) by gender, state | transpose
| column     | row 1 | row 2 | row 3 | row 4 |
|-------------|-------|-------|-------|-------|
| sum(age)    | 36    | 33    | 32    | 28    |
| gender      | M     | M     | M     | F     |
| state       | TN    | MD    | IL    | VA    |




**Is your feature request related to a problem?**
Implement SPL equivalent in PPL for transpose

**What solution would you like?**
A clear and concise description of what you want to happen.

**What alternatives have you considered?**
A clear and concise description of any alternative solutions or features you've considered.

**Do you have any additional context?**
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

Labels

PPLPiped processing languageenhancementNew feature or request

Type

No type

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions