@@ -931,6 +931,7 @@ def fetch(self) -> List[Union[List[Any]], Any]:
931
931
932
932
def _to_segments (self , rows : _SpooledProtocolResponseTO ) -> SpooledData :
933
933
encoding = rows ["encoding" ]
934
+ metadata = rows ["metadata" ] if "metadata" in rows else None
934
935
segments = []
935
936
for segment in rows ["segments" ]:
936
937
segment_type = segment ["type" ]
@@ -943,7 +944,7 @@ def _to_segments(self, rows: _SpooledProtocolResponseTO) -> SpooledData:
943
944
else :
944
945
raise ValueError (f"Unsupported segment type: { segment_type } " )
945
946
946
- return SpooledData (encoding , segments )
947
+ return SpooledData (encoding , metadata , segments )
947
948
948
949
def cancel (self ) -> None :
949
950
"""Cancel the current query"""
@@ -1024,6 +1025,7 @@ def _parse_retry_after_header(retry_after):
1024
1025
# Trino Spooled protocol transfer objects
1025
1026
class _SpooledProtocolResponseTO (TypedDict ):
1026
1027
encoding : Literal ["json" , "json+std" , "json+lz4" ]
1028
+ metadata : _SegmentMetadataTO
1027
1029
segments : List [_SegmentTO ]
1028
1030
1029
1031
@@ -1168,10 +1170,12 @@ class SpooledData:
1168
1170
1169
1171
Attributes:
1170
1172
encoding (str): The encoding format of the spooled data.
1173
+ metadata (_SegmentMetadataTO): Metadata for all segments
1171
1174
segments (List[Segment]): The list of segments in the spooled data.
1172
1175
"""
1173
- def __init__ (self , encoding : str , segments : List [Segment ]) -> None :
1176
+ def __init__ (self , encoding : str , metadata : _SegmentMetadataTO , segments : List [Segment ]) -> None :
1174
1177
self ._encoding = encoding
1178
+ self ._metadata = metadata
1175
1179
self ._segments = segments
1176
1180
self ._segments_iterator = iter (segments )
1177
1181
@@ -1190,7 +1194,7 @@ def __next__(self) -> Tuple["SpooledData", "Segment"]:
1190
1194
return self , next (self ._segments_iterator )
1191
1195
1192
1196
def __repr__ (self ):
1193
- return (f"SpooledData(encoding={ self ._encoding } , segments={ list (self ._segments )} )" )
1197
+ return (f"SpooledData(encoding={ self ._encoding } , metadata= { self . _metadata } , segments={ list (self ._segments )} )" )
1194
1198
1195
1199
1196
1200
class SegmentIterator :
0 commit comments