Skip to content

qjoin - request - build a lookup table as a final collection #6

@FabienArcellier

Description

@FabienArcellier

a lookup table allows to retrieve an element of a final collection from a key. This key can only be a base collection key.

generate a lookup table from a key in the base collection

space_crafts_lookup = qjoin.on(spacecrafts)
                           .join(spacecrafts_properties, key='name')
                           .as_lookup(key='name')

space_info = space_crafts_lookup['Kepler']
print(space_info[0]['cospar_id'])

construct a lookup table from an artificial key in the base collection

space_crafts_lookup = qjoin.on(spacecrafts)
                           .join(spacecrafts_properties, key='name')
                           .as_lookup(key=lambda s: s['name'])

space_info = space_crafts_lookup['Kepler']
print(space_info[0]['cospar_id'])

the lookup table is made on a non-unique attribute

If the lookup table is made with a key that is not unique, the value of a non-unique key is the last element that has that value in the base collection

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions