Skip to content

Commit 9fd301c

Browse files
committed
fix: add functions for data uris
1 parent 77fdad5 commit 9fd301c

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/query_farm_server_base/flight_handling.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import base64
2+
import io
23
import json
34
from collections.abc import Callable, Generator
45
from dataclasses import dataclass
@@ -78,6 +79,13 @@ def endpoint(
7879
)
7980

8081

82+
def serialize_arrow_ipc_table(table: pa.Table) -> bytes:
83+
sink = io.BytesIO()
84+
with pa.ipc.new_stream(sink, table.schema) as writer:
85+
writer.write_table(table)
86+
return sink.getvalue()
87+
88+
8189
def dict_to_msgpack_data_uri(data: dict[str, Any]) -> str:
8290
"""
8391
Convert a dictionary to a data URI with MessagePack encoding.

0 commit comments

Comments
 (0)