Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue104; get valid key value combinations #234

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nickeopti
Copy link
Contributor

@nickeopti nickeopti commented Sep 2, 2021

Make it possible to discover which key values exists -- optionally after filtering for specific key values.
This closes #104.

Can be called as

>>> /valid_values
{
    'region': ['a', 'b, 'c'],
    'date': ['20180101', '20190101', '20200101'],
    'band': ['E', 'T', 'I']
}

to get all possible values for each key,
or

>>> /valid_values?region=a
{
    'region': ['a'],
    'date': ['20180101', '20190101', '20200101'],
    'band': ['1', '2', '3']
}

to get all valid values for each key, when one or more keys are set,
or

>>> /valid_values?region=a&band=[1,2]
{
    'region': ['a'],
    'date': 'date': ['20180101', '20190101'],
    'band': ['1', '2']
}

where, in the last query, notice that the multi-querying syntax introduced from issue #33 is supported.

@codecov
Copy link

codecov bot commented Sep 2, 2021

Codecov Report

Merging #234 (5c930dc) into main (9bd5873) will increase coverage by 0.00%.
The diff coverage is 98.76%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #234   +/-   ##
=======================================
  Coverage   98.57%   98.58%           
=======================================
  Files          45       47    +2     
  Lines        2251     2332   +81     
  Branches      287      303   +16     
=======================================
+ Hits         2219     2299   +80     
  Misses         18       18           
- Partials       14       15    +1     
Impacted Files Coverage Δ
terracotta/drivers/mysql.py 99.62% <95.00%> (-0.38%) ⬇️
terracotta/drivers/base.py 100.00% <100.00%> (ø)
terracotta/drivers/sqlite.py 100.00% <100.00%> (ø)
terracotta/handlers/valid_values.py 100.00% <100.00%> (ø)
terracotta/server/flask_api.py 90.54% <100.00%> (+0.26%) ⬆️
terracotta/server/valid_values.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9bd5873...5c930dc. Read the comment docs.

@dionhaefner
Copy link
Collaborator

Thanks for the implementation, looks pretty good. But I'm a bit hesitant to support this without a clear use case. Adding another SQL command complicates the drivers even more, so this looks a bit like feature creep to me.

What do you think @j08lue? Have you ever missed this feature?

@j08lue
Copy link
Collaborator

j08lue commented Nov 25, 2021

Have you ever missed this feature?

I am not sure. Not me, personally. Maybe @bertearazvan can comment whether we are doing this in any frontend:

  1. Fetch all /datasets into the client
  2. Scan datasets to get unique values for each key

If we do that anywhere, e.g. in order to create menus for selecting from them or so, this endpoint could replace that. But the result can be misleading - these are the unique values, but you do not know whether any combination of them exists until you check (e.g. /datasets).

@bertearazvan
Copy link
Contributor

We have the following use cases where this can be useful:

  • When fetching all the dates available for an RGB raster. We always query for the B01 band, which works. This I find would be a more "correct" approach.
  • Usually very useful for fetching all the dates available for a product.
  • In the ET4FAO app https://et4fao.dhigroup.com/#/, we are filtering through the available datasets that comply with the user's selection. This can be useful in this case too if there would be many more datasets, and it would be heavy to filter through them in the browser.

I think we can benefit from this in the future when dealing with a large number of datasets - @j08lue like LBST, maybe?

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.

Supply a way to retrieve unique key values
4 participants