miller/test/cases/verb-step
John Kerl e415682e61
Allow more step -a options to specify the number of records back (#1002) (#2190)
* Allow step -a shift_lag/shift_lead/delta/ratio to specify records back/forward (#1002)

Extends the slwin_m_n naming convention to more steppers: shift_lag_12
refers 12 records back, shift_lead_4 refers 4 records forward, and
likewise delta_N, ratio_N, and shift_N. The unsuffixed forms keep their
existing 1-record-back/forward behavior and output field names.

Backward-looking steppers cache copies of previous values in a
fixed-size ring buffer (tValueRing) in their own state, following the
existing pattern of not reading from the window keeper's already-emitted
records, to avoid races with downstream transformers. shift_lead_N uses
the existing forward-window machinery shared with slwin.

Also adds nil guards to all steppers' process functions for the case
where the record at the window center lacks the stepped field, which
previously panicked (pre-existing on main, e.g.
"mlr step -a delta,shift_lead -f x" or "-a slwin_1_1" over
heterogeneous data), and which the new parameterized combinations make
easier to reach.

Includes unit tests, regression cases 0024-0027, and regenerated help
text / docs / man page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Clarify step -a help text: both plain and _{n} stepper forms are valid (#1002)

Per review on #2190: descriptions like "E.g. delta_7 for 7 records
back" read as if the suffixed form were the only syntax. Reword the
shift, shift_lag, shift_lead, delta, and ratio descriptions to state
both forms explicitly -- e.g. "Use delta or equivalently delta_1 for
the previous record, or delta_{n} for n records back" -- using the {n}
placeholder style, and update the matching usage paragraph and
reference-verbs prose. Regenerate help-derived docs, man page, and
cli-help regression expectation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Give a specific error for invalid stepper count suffixes (#1002)

Per review on #2190: "mlr step -a delta_0" (or delta_-1, delta_x, etc.)
previously reported the generic 'stepper "delta_0" not found'. Now,
when the name prefixes a known count-suffix stepper (shift, shift_lag,
shift_lead, delta, ratio) but the suffix is not a positive integer, the
error is:

    mlr step: stepper "delta_0": count must be a positive integer

Truly unknown stepper names keep the existing "not found" message.
Adds should-fail regression cases for delta_0 and delta_-1, and unit
tests for the detection helper.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 16:39:48 -04:00
..
0001 Add mlr step -a rprod for running products (#1228) 2023-03-12 13:32:23 -04:00
0002 Add mlr step -a rprod for running products (#1228) 2023-03-12 13:32:23 -04:00
0003 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0004 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0005 Add mlr step -a rprod for running products (#1228) 2023-03-12 13:32:23 -04:00
0006 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0007 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0008 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0009 Standardize Go-package structure (#746) 2021-11-11 14:15:13 -05:00
0010 Standardize Go-package structure (#746) 2021-11-11 14:15:13 -05:00
0011 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0012 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0013 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0014 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0015 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0016 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0017 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0018 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0019 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0020 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0021 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0022 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0023 Use fixed OFMT for multi-platform regression-testing (#988) 2022-03-16 14:44:42 -04:00
0024 Allow more step -a options to specify the number of records back (#1002) (#2190) 2026-07-14 16:39:48 -04:00
0025 Allow more step -a options to specify the number of records back (#1002) (#2190) 2026-07-14 16:39:48 -04:00
0026 Allow more step -a options to specify the number of records back (#1002) (#2190) 2026-07-14 16:39:48 -04:00
0027 Allow more step -a options to specify the number of records back (#1002) (#2190) 2026-07-14 16:39:48 -04:00
bad-count-negative Allow more step -a options to specify the number of records back (#1002) (#2190) 2026-07-14 16:39:48 -04:00
bad-count-zero Allow more step -a options to specify the number of records back (#1002) (#2190) 2026-07-14 16:39:48 -04:00