MCPcopy Create free account
hub / github.com/apache/arrow / test_flight_do_put_metadata

Function test_flight_do_put_metadata

python/pyarrow/tests/test_flight.py:1897–1916  ·  view source on GitHub ↗

Try a simple do_put call with metadata.

()

Source from the content-addressed store, hash-verified

1895
1896
1897def test_flight_do_put_metadata():
1898 """Try a simple do_put call with metadata."""
1899 data = [
1900 pa.array([-10, -5, 0, 5, 10])
1901 ]
1902 table = pa.Table.from_arrays(data, names=['a'])
1903
1904 with MetadataFlightServer() as server, \
1905 FlightClient(('localhost', server.port)) as client:
1906 writer, metadata_reader = client.do_put(
1907 flight.FlightDescriptor.for_path(''),
1908 table.schema)
1909 with writer:
1910 for idx, batch in enumerate(table.to_batches(max_chunksize=1)):
1911 metadata = struct.pack('<i', idx)
1912 writer.write_with_metadata(batch, metadata)
1913 buf = metadata_reader.read()
1914 assert buf is not None
1915 server_idx, = struct.unpack('<i', buf.to_pybytes())
1916 assert idx == server_idx
1917
1918
1919@pytest.mark.numpy

Callers

nothing calls this directly

Calls 8

FlightClientClass · 0.90
to_batchesMethod · 0.80
arrayMethod · 0.45
do_putMethod · 0.45
packMethod · 0.45
readMethod · 0.45
unpackMethod · 0.45

Tested by

no test coverage detected