@@ -931,6 +931,7 @@ def fetch(self) -> List[Union[List[Any]], Any]:
931931
932932 def _to_segments (self , rows : _SpooledProtocolResponseTO ) -> SpooledData :
933933 encoding = rows ["encoding" ]
934+ metadata = rows ["metadata" ] if "metadata" in rows else None
934935 segments = []
935936 for segment in rows ["segments" ]:
936937 segment_type = segment ["type" ]
@@ -943,7 +944,7 @@ def _to_segments(self, rows: _SpooledProtocolResponseTO) -> SpooledData:
943944 else :
944945 raise ValueError (f"Unsupported segment type: { segment_type } " )
945946
946- return SpooledData (encoding , segments )
947+ return SpooledData (encoding , metadata , segments )
947948
948949 def cancel (self ) -> None :
949950 """Cancel the current query"""
@@ -1024,6 +1025,7 @@ def _parse_retry_after_header(retry_after):
10241025# Trino Spooled protocol transfer objects
10251026class _SpooledProtocolResponseTO (TypedDict ):
10261027 encoding : Literal ["json" , "json+std" , "json+lz4" ]
1028+ metadata : _SegmentMetadataTO
10271029 segments : List [_SegmentTO ]
10281030
10291031
@@ -1168,10 +1170,12 @@ class SpooledData:
11681170
11691171 Attributes:
11701172 encoding (str): The encoding format of the spooled data.
1173+ metadata (_SegmentMetadataTO): Metadata for all segments
11711174 segments (List[Segment]): The list of segments in the spooled data.
11721175 """
1173- def __init__ (self , encoding : str , segments : List [Segment ]) -> None :
1176+ def __init__ (self , encoding : str , metadata : _SegmentMetadataTO , segments : List [Segment ]) -> None :
11741177 self ._encoding = encoding
1178+ self ._metadata = metadata
11751179 self ._segments = segments
11761180 self ._segments_iterator = iter (segments )
11771181
@@ -1190,7 +1194,7 @@ def __next__(self) -> Tuple["SpooledData", "Segment"]:
11901194 return self , next (self ._segments_iterator )
11911195
11921196 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 )} )" )
11941198
11951199
11961200class SegmentIterator :
0 commit comments