mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-17 16:38:54 +00:00
fix: stats1 null_count with --fr regex gives wrong results (#1994)
When using --fr (regex field selector) with stats1 -a null_count, void (empty) field values were unconditionally skipped in ingestWithValueFieldRegexes, causing null_count to always report 0. The non-regex path (ingestWithoutValueFieldRegexes) already had a special case that allows void values through for null_count accumulators. This commit adds the same exception to the regex path. Fixes #1639 Co-authored-by: cobyfrombrooklyn-bot <cobyfrombrooklyn-bot@users.noreply.github.com>
This commit is contained in:
parent
4c781739c0
commit
f20da1953e
5 changed files with 12 additions and 1 deletions
|
|
@ -578,7 +578,9 @@ func (tr *TransformerStats1) ingestWithValueFieldRegexes(
|
|||
// The accumulator has been initialized with default values;
|
||||
// continue here. (If we were to continue outside of this loop
|
||||
// we would be failing to construct the accumulator.)
|
||||
continue
|
||||
if accumulatorName != "null_count" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
namedAccumulator.Ingest(valueFieldValue)
|
||||
}
|
||||
|
|
|
|||
1
test/cases/verb-stats1-regexed-field-names/0008/cmd
Normal file
1
test/cases/verb-stats1-regexed-field-names/0008/cmd
Normal file
|
|
@ -0,0 +1 @@
|
|||
mlr --icsv --ifs "|" --oxtab stats1 -a null_count --fr ".*" test/input/null-count-pipe.csv
|
||||
0
test/cases/verb-stats1-regexed-field-names/0008/experr
Normal file
0
test/cases/verb-stats1-regexed-field-names/0008/experr
Normal file
4
test/cases/verb-stats1-regexed-field-names/0008/expout
Normal file
4
test/cases/verb-stats1-regexed-field-names/0008/expout
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Id_null_count 0
|
||||
Type_null_count 3
|
||||
Other Type_null_count 1
|
||||
Number_null_count 0
|
||||
4
test/input/null-count-pipe.csv
Normal file
4
test/input/null-count-pipe.csv
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
Id|Type|Other Type|Number
|
||||
a||foo|1
|
||||
b||bar|2
|
||||
c|||1
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue