Skip to content

Commit 02dca12

Browse files
committed
feat: pivotp add --maintain-order flag
1 parent 5f892a1 commit 02dca12

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/cmd/pivotp.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ pivotp options:
4545
Will only work if there is one value column, otherwise
4646
it falls back to `first`
4747
[default: smart]
48-
--sort-columns Sort the transposed columns by name. Default is by order of discovery.
48+
--sort-columns Sort the transposed columns by name.
49+
--maintain-order Maintain the order of the input columns.
4950
--col-separator <arg> The separator in generated column names in case of multiple --values columns.
5051
[default: _]
5152
--validate Validate a pivot by checking the pivot column(s)' cardinality.
@@ -102,6 +103,7 @@ struct Args {
102103
flag_values: Option<String>,
103104
flag_agg: Option<String>,
104105
flag_sort_columns: bool,
106+
flag_maintain_order: bool,
105107
flag_col_separator: String,
106108
flag_validate: bool,
107109
flag_try_parsedates: bool,
@@ -707,7 +709,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
707709
index_selector,
708710
values_selector,
709711
agg,
710-
args.flag_sort_columns,
712+
args.flag_maintain_order,
711713
separator,
712714
)
713715
.collect()?;
@@ -727,8 +729,7 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
727729
.collect()?;
728730
}
729731

730-
// Sort columns if requested - the maintain_order parameter controls discovery order,
731-
// but we need to explicitly sort column names alphabetically when flag is set
732+
// Sort columns if requested
732733
if args.flag_sort_columns {
733734
let columns = pivot_result
734735
.get_column_names()

0 commit comments

Comments
 (0)