2
2
from dataclasses import dataclass
3
3
from datetime import datetime
4
4
from pathlib import Path
5
- from typing import Any , Dict , List , Mapping , Optional , Sequence , Tuple
5
+ from typing import Any , Dict , List , Mapping , Optional , Sequence , Tuple , Union
6
+ import bson
6
7
7
8
from google .protobuf .struct_pb2 import Struct
8
9
from grpclib .client import Channel , Stream
@@ -241,7 +242,7 @@ async def tabular_data_by_filter(
241
242
LOGGER .error (f"Failed to write tabular data to file { dest } " , exc_info = e )
242
243
return data , response .count , response .last
243
244
244
- async def tabular_data_by_sql (self , organization_id : str , sql_query : str ) -> List [Dict [str , ValueTypes ]]:
245
+ async def tabular_data_by_sql (self , organization_id : str , sql_query : str ) -> List [Dict [str , Union [ ValueTypes , datetime ] ]]:
245
246
"""Obtain unified tabular data and metadata, queried with SQL.
246
247
247
248
::
@@ -264,9 +265,9 @@ async def tabular_data_by_sql(self, organization_id: str, sql_query: str) -> Lis
264
265
"""
265
266
request = TabularDataBySQLRequest (organization_id = organization_id , sql_query = sql_query )
266
267
response : TabularDataBySQLResponse = await self ._data_client .TabularDataBySQL (request , metadata = self ._metadata )
267
- return [struct_to_dict ( struct ) for struct in response .data ]
268
+ return [bson . decode ( bson_bytes ) for bson_bytes in response .raw_data ]
268
269
269
- async def tabular_data_by_mql (self , organization_id : str , mql_binary : List [bytes ]) -> List [Dict [str , ValueTypes ]]:
270
+ async def tabular_data_by_mql (self , organization_id : str , mql_binary : List [bytes ]) -> List [Dict [str , Union [ ValueTypes , datetime ] ]]:
270
271
"""Obtain unified tabular data and metadata, queried with MQL.
271
272
272
273
::
@@ -303,7 +304,7 @@ async def tabular_data_by_mql(self, organization_id: str, mql_binary: List[bytes
303
304
"""
304
305
request = TabularDataByMQLRequest (organization_id = organization_id , mql_binary = mql_binary )
305
306
response : TabularDataByMQLResponse = await self ._data_client .TabularDataByMQL (request , metadata = self ._metadata )
306
- return [struct_to_dict ( struct ) for struct in response .data ]
307
+ return [bson . decode ( bson_bytes ) for bson_bytes in response .raw_data ]
307
308
308
309
async def binary_data_by_filter (
309
310
self ,
0 commit comments