Skip to content

Export tabbook using multiple filters #424

Open
@jamesrkg

Description

@jamesrkg

See: https://github.com/Crunch-io/scrunch/blob/master/scrunch/subentity.py#L87-L178

Multitable.export and Multitable.export_tabbook both take a single filter, but the API supports multiple filters in combination (per docs here: https://crunch.io/api/reference/#post-/datasets/-dataset_id-/multitables/-multitable_id-/export/).

Therefore, we need to be able to export using multiple filters, for example:

mt = ds.multitables[mt_name]
mt.export(..., filters=[fltr1, fltr2])

I believe the only change needed is in Multitable.export_tabbook here:

        # add filter to multitable
        if filter:
            if isinstance(filter, Filter):
                payload['filter'] = [{'filter': filter.resource.self}]
            else:
                raise ValueError('filter param must be a Filter instance')

Where filter should support a list of filters, and be converted to a list if passed as a string originally, then [{'filter': filter.resource.self}] should instead be a list comprehension across that list such as: [{'filter': fltr.resource.self} for fltr in filter].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions