Skip to content

Commit effa13b

Browse files
committed
refactor: frequency also assign a special rank of 0 to <ALL_UNIQUE> values
1 parent 6c661ac commit effa13b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/cmd/frequency.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ the already inferred dates and boolean types.
4545
NOTE: "Complete" Frequency Tables:
4646
4747
By default, ID columns will have an "<ALL UNIQUE>" value with count equal to
48-
rowcount and percentage set to 100. This is done by using the stats cache to
49-
fetch each column's cardinality - allowing qsv to short-circuit frequency
50-
compilation and eliminate the need to maintain a hashmap for ID columns.
48+
rowcount and percentage set to 100 with a rank of 0. This is done by using the
49+
stats cache to fetch each column's cardinality - allowing qsv to short-circuit
50+
frequency compilation and eliminate the need to maintain a hashmap for ID columns.
5151
5252
If you wish to compile a "complete" frequency table even for ID columns, set
5353
QSV_STATSCACHE_MODE to "none". This will force the frequency command to compute
@@ -438,7 +438,7 @@ impl Args {
438438
count: row_count,
439439
percentage: 100.0,
440440
formatted_percentage: self.format_percentage(100.0, abs_dec_places),
441-
rank: 1.0, // Rank 1 for all-unique headers
441+
rank: 0.0, // Rank 0 for all-unique headers
442442
});
443443
} else {
444444
// Process regular frequencies

tests/test_frequency.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ fn frequency_all_unique() {
461461
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
462462
let expected = vec![
463463
svec!["field", "value", "count", "percentage", "rank"],
464-
svec!["case_enquiry_id", "<ALL_UNIQUE>", "100", "100", "1"],
464+
svec!["case_enquiry_id", "<ALL_UNIQUE>", "100", "100", "0"],
465465
];
466466
assert_eq!(got, expected);
467467
}
@@ -485,7 +485,7 @@ fn frequency_all_unique_with_stats_cache() {
485485
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
486486
let expected = vec![
487487
svec!["field", "value", "count", "percentage", "rank"],
488-
svec!["case_enquiry_id", "<ALL_UNIQUE>", "100", "100", "1"],
488+
svec!["case_enquiry_id", "<ALL_UNIQUE>", "100", "100", "0"],
489489
];
490490
assert_eq!(got, expected);
491491
}
@@ -539,7 +539,7 @@ fn frequency_all_unique_with_stats_cache_alt_all_unique_text() {
539539
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
540540
let expected = vec![
541541
svec!["field", "value", "count", "percentage", "rank"],
542-
svec!["case_enquiry_id", "<ALLE EINZIGARTIG>", "100", "100", "1"],
542+
svec!["case_enquiry_id", "<ALLE EINZIGARTIG>", "100", "100", "0"],
543543
];
544544
assert_eq!(got, expected);
545545
}
@@ -557,7 +557,7 @@ fn frequency_all_unique_stats_cache_default() {
557557
let got: Vec<Vec<String>> = wrk.read_stdout(&mut cmd);
558558
let expected = vec![
559559
svec!["field", "value", "count", "percentage", "rank"],
560-
svec!["case_enquiry_id", "<ALL_UNIQUE>", "100", "100", "1"],
560+
svec!["case_enquiry_id", "<ALL_UNIQUE>", "100", "100", "0"],
561561
];
562562
assert_eq!(got, expected);
563563
}

0 commit comments

Comments
 (0)