22from dataclasses import dataclass
33from datetime import datetime
44from 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
67
78from google .protobuf .struct_pb2 import Struct
89from grpclib .client import Channel , Stream
@@ -241,7 +242,7 @@ async def tabular_data_by_filter(
241242 LOGGER .error (f"Failed to write tabular data to file { dest } " , exc_info = e )
242243 return data , response .count , response .last
243244
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 ] ]]:
245246 """Obtain unified tabular data and metadata, queried with SQL.
246247
247248 ::
@@ -264,9 +265,9 @@ async def tabular_data_by_sql(self, organization_id: str, sql_query: str) -> Lis
264265 """
265266 request = TabularDataBySQLRequest (organization_id = organization_id , sql_query = sql_query )
266267 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 ]
268269
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 ] ]]:
270271 """Obtain unified tabular data and metadata, queried with MQL.
271272
272273 ::
@@ -303,7 +304,7 @@ async def tabular_data_by_mql(self, organization_id: str, mql_binary: List[bytes
303304 """
304305 request = TabularDataByMQLRequest (organization_id = organization_id , mql_binary = mql_binary )
305306 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 ]
307308
308309 async def binary_data_by_filter (
309310 self ,
0 commit comments