@@ -269,7 +269,11 @@ async def tabular_data_by_sql(self, organization_id: str, sql_query: str) -> Lis
269269 response : TabularDataBySQLResponse = await self ._data_client .TabularDataBySQL (request , metadata = self ._metadata )
270270 return [bson .decode (bson_bytes ) for bson_bytes in response .raw_data ]
271271
272- async def tabular_data_by_mql (self , organization_id : str , mql_binary : List [bytes ]) -> List [Dict [str , Union [ValueTypes , datetime ]]]:
272+ async def tabular_data_by_mql (
273+ self ,
274+ organization_id : str ,
275+ mql_query : Union [List [bytes ], Dict [str , Union [ValueTypes , datetime ]]]
276+ ) -> List [Dict [str , Union [ValueTypes , datetime ]]]:
273277 """Obtain unified tabular data and metadata, queried with MQL.
274278
275279 ::
@@ -288,14 +292,15 @@ async def tabular_data_by_mql(self, organization_id: str, mql_binary: List[bytes
288292 Args:
289293 organization_id (str): The ID of the organization that owns the data.
290294 You can obtain your organization ID from the Viam app's organization settings page.
291- mql_binary ( List[bytes]): The MQL query to run as a list of BSON queries. You can encode your bson queries using a library like
292- `pymongo` .
295+ mql_query (Union[ List[bytes], Dict[str, Union[ValueTypes, datetime]]] ): The MQL query to run as a list of BSON queries.
296+ Note: Use a dictionary for `mql_query` as support for bytes will be removed in the future .
293297
294298 Returns:
295299 List[Dict[str, Union[ValueTypes, datetime]]]: An array of decoded BSON data objects.
296300
297301 For more information, see `Data Client API <https://docs.viam.com/appendix/apis/data-client/>`_.
298302 """
303+ mql_binary = bson .encode (mql_query ) if isinstance (mql_query , dict ) else mql_query
299304 request = TabularDataByMQLRequest (organization_id = organization_id , mql_binary = mql_binary )
300305 response : TabularDataByMQLResponse = await self ._data_client .TabularDataByMQL (request , metadata = self ._metadata )
301306 return [bson .decode (bson_bytes ) for bson_bytes in response .raw_data ]
0 commit comments