Skip to content

Commit

Permalink
Make sure that concatenate always outputs all fields (#38)
Browse files Browse the repository at this point in the history
* Make sure that concatenate always outputs all fields

* v0.0.28
  • Loading branch information
akariv committed Oct 17, 2018
1 parent 28f4f6c commit 4ef7131
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dataflows/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.27
0.0.28
1 change: 1 addition & 0 deletions dataflows/processors/concatenate.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def func(package):
package.pkg.descriptor['resources'] = new_resources
yield package.pkg

needed_fields = sorted(fields.keys())
it = iter(package)
for resource in it:
if matcher.match(resource.res.name):
Expand Down
15 changes: 11 additions & 4 deletions tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,20 @@ def test_concatenate():
{'c': 6, 'd': 7},
],
concatenate({
'f1': ['a', 'c'],
'f2': ['b', 'd']
'f1': ['a'],
'f2': ['b', 'c'],
'f3': ['d']
})
)
results, _, _ = f.results()
d = [(r['f1'], r['f2']) for r in results[0]]
assert d == list(zip(range(1,7), range(2, 8)))
assert results[0] == [
{'f1': 1, 'f2': 2, 'f3': None},
{'f1': 2, 'f2': 3, 'f3': None},
{'f1': 3, 'f2': 4, 'f3': None},
{'f1': None, 'f2': 4, 'f3': 5},
{'f1': None, 'f2': 5, 'f3': 6},
{'f1': None, 'f2': 6, 'f3': 7}
]


def test_filter_rows():
Expand Down

0 comments on commit 4ef7131

Please sign in to comment.