Skip to content

Support for multiple nested query options #348

@webb-ben

Description

@webb-ben

Describe the feature you'd like and what it will do

I would like to use multiple nested query options when writing SensorThings API REST queries. Specifically I am looking to implement some sort of query pattern like

/sensorthings/v1.1/Datastreams?$expand=Observations($top=1;$select=result)

Why is this feature important?

I am looking to align the pygeoapi Sensorthings - OGC API Feature provider with the existing FROST-Server Sensorthings endpoint. One of the query patterns necessary for this is multiple nested parameters as described in the FROST documentation here.

Is your feature request related to a problem? Please describe.

When I do the query now, I get this as the content in the HTTP 500 error.

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/ninja/operation.py", line 120, in run
    result = self.view_func(request, **values)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sensorthings/main.py", line 206, in auth_wrapper
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sensorthings/components/datastreams/views.py", line 57, in get_datastream
    return request.engine.get_entity(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sensorthings/engine.py", line 139, in get_entity
    entities, count = self.fetch_entities(
                      ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sensorthings/engine.py", line 273, in fetch_entities
    entities = self.insert_related_entities(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sensorthings/engine.py", line 376, in insert_related_entities
    expand_properties = self.parse_expand(
                        ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sensorthings/engine.py", line 660, in parse_expand
    expand_property['query_params'] = ListQueryParams(**expand_property['query_params']).dict()
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 176, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for ListQueryParams
$top
  Input should be a valid integer, unable to parse string as an integer [type=int_parsing, input_value='1;$select', input_type=str]
    For further information visit https://errors.pydantic.dev/2.7/v/int_parsing

Any additional comments?

I couldn't anything about this in the SensorThings specification - so this may be a feature that FROST has extended beyond the specification?

Metadata

Metadata

Assignees

Labels

backendAssociated with the backend repository🐞bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions