blaze / blaze/odo

KeyError with mongo backend and collection of variable documents

Open
#445 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1k
Forks
131
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am using mongodb as backend.

I got these lines of code:

```
data_col = "mongodb://localhost/::"

import odo
resource = odo.resource(data_col)
dshape = odo.discover(resource)
odo.convert(list,resource)
```

unfortunately i end up wit a KeyError. Something like that

> 178 @convert.register(list, Iterator, cost=1.0)
> 179 def iterator_to_list(seq, **kwargs):
> --> 180 return list(seq)
> 181
> 182
> KeyError: u'search:seed'

The problem is that in my collection in mongodb not all documents has this keyword : `search:seed`

Even if I provide the correct dshape, I still get the same error.

The problem looks rather related to the use of

`toolz.itertoolz.pluck(ind, seqs, default='__no__default__')`

in this method

```
def _into_iter_mongodb(coll, columns=None, dshape=None):
""" Into helper function

Return both a lazy sequence of tuples and a list of column names
"""
seq = coll.find()
if not columns and dshape:
columns = dshape.measure.names
elif not columns:
item = next(seq)
seq = concat([[item], seq])
columns = sorted(item.keys())
columns.remove('_id')
return columns, pluck(columns, seq)
```

because we are not using the `default` option that would allow to deal with this case.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.