Skip to content

fix(steps): make field_pack target resource re-readable - #1793

Open
Sanjays2402 wants to merge 1 commit into
frictionlessdata:mainfrom
Sanjays2402:fix/field-pack-reread
Open

fix(steps): make field_pack target resource re-readable#1793
Sanjays2402 wants to merge 1 commit into
frictionlessdata:mainfrom
Sanjays2402:fix/field-pack-reread

Conversation

@Sanjays2402

Copy link
Copy Markdown

field_pack assigned the generator returned by iterpack/iterpackdict straight to resource.data. A generator is exhausted after one pass, so the transformed resource returned its rows on the first read_rows() and zero rows on every later read (and drained the source resource with it). Assigning a functools.partial instead makes each read start a fresh generator — the inline parser already calls a non-iterable data value to get its iterator.

Added a regression test that reads the packed resource twice; it fails on main and passes with the fix.

field_pack assigned the generator returned by iterpack/iterpackdict
directly to resource.data. A generator is exhausted after one pass, so
the transformed resource yielded its rows only on the first read and
returned zero rows on every subsequent read_rows()/validate() call
(and the source resource, which shares the underlying petl view, was
drained with it).

Assign a functools.partial instead: the inline parser already calls a
non-iterable data value to obtain a fresh iterator, so each read starts
a new generator.

Closes frictionlessdata#1476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong stats on repeated attempts of read after transform

1 participant