Skip to content

Commit

Permalink
DATA-3756 Update TabularDataByMQL to have optional bool for use_recen…
Browse files Browse the repository at this point in the history
…t_data (#845)
  • Loading branch information
vijayvuyyuru authored Feb 11, 2025
1 parent b67f405 commit 787c605
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/viam/app/data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ async def tabular_data_by_sql(self, organization_id: str, sql_query: str) -> Lis

@_alias_param("query", param_alias="mql_binary")
async def tabular_data_by_mql(
self, organization_id: str, query: Union[List[bytes], List[Dict[str, Any]]]
self, organization_id: str, query: Union[List[bytes], List[Dict[str, Any]]], use_recent_data: Optional[bool] = None
) -> List[Dict[str, Union[ValueTypes, datetime]]]:
"""Obtain unified tabular data and metadata, queried with MQL.
Expand All @@ -367,14 +367,15 @@ async def tabular_data_by_mql(
query (Union[List[bytes], List[Dict[str, Any]]]): The MQL query to run, as a list of MongoDB aggregation pipeline stages.
Note: Each stage can be provided as either a dictionary or raw BSON bytes, but support for bytes will be removed in the future,
so using a dictionary is preferred.
use_recent_data (bool): Whether to query blob storage or your recent data store. Defaults to `False`
Returns:
List[Dict[str, Union[ValueTypes, datetime]]]: An array of decoded BSON data objects.
For more information, see `Data Client API <https://docs.viam.com/dev/reference/apis/data-client/#tabulardatabymql>`_.
"""
binary: List[bytes] = [bson.encode(query) for query in query] if isinstance(query[0], dict) else query # type: ignore
request = TabularDataByMQLRequest(organization_id=organization_id, mql_binary=binary)
request = TabularDataByMQLRequest(organization_id=organization_id, mql_binary=binary, use_recent_data=use_recent_data)
response: TabularDataByMQLResponse = await self._data_client.TabularDataByMQL(request, metadata=self._metadata)
return [bson.decode(bson_bytes) for bson_bytes in response.raw_data]

Expand Down

0 comments on commit 787c605

Please sign in to comment.