Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ FlightStreamChunkBuffer::FlightStreamChunkBuffer(
arrow::Result<std::unique_ptr<FlightStreamReader>> result;
std::shared_ptr<FlightSqlClient> temp_flight_sql_client;
auto endpoint_locations = endpoint.locations;
if (endpoint_locations.empty()) {
// list of Locations needs to be empty to proceed
if (endpoint_locations.empty() ||
endpoint_locations[0].scheme() == Location::ReuseConnection().scheme()) {
result = flight_sql_client.DoGet(call_options, ticket);
} else {
// If it is non-empty, the driver should create a FlightSqlClient to connect to one
Expand Down Expand Up @@ -67,8 +67,8 @@ FlightStreamChunkBuffer::FlightStreamChunkBuffer(
bool is_not_empty = result.ok() && (result.ValueOrDie().data != nullptr);

// If result is valid, save the temp Flight SQL Client for future stream reader
// call. temp_flight_sql_client is intentionally null if the list of endpoint
// Locations is empty.
// call. temp_flight_sql_client is intentionally null if the endpoint is read
// from the original connection.
// After all data is fetched from reader, the temp client is closed.
if (is_not_ok || is_not_empty) {
return std::make_optional(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,27 @@ TEST_F(FlightStreamChunkBufferTest, TestMultipleEndpointsInt) {
// In total 10 batches should be returned.
ASSERT_EQ(10, num_chunks);
}

TEST_F(FlightStreamChunkBufferTest, TestReuseConnectionLocation) {
ASSERT_OK_AND_ASSIGN(auto client,
arrow::flight::FlightClient::Connect(server_location1));
FlightSqlClient server1_client(std::move(client));

FlightEndpoint endpoint(
{Ticket{"ticket-ints-1"}, {Location::ReuseConnection()}, std::nullopt, {}});
FlightDescriptor descr{FlightDescriptor::PATH, "", {"examples", "ints"}};
auto info_ptr = std::make_shared<FlightInfo>(arrow::flight::MakeFlightInfo(
*arrow::flight::ExampleIntSchema(), descr, {endpoint}, 1000, 100000, false, ""));

FlightStreamChunkBuffer chunk_buffer(server1_client, FlightClientOptions::Defaults(),
FlightCallOptions(), info_ptr);

FlightStreamChunk current_chunk;
int num_chunks = 0;
while (chunk_buffer.GetNext(&current_chunk)) {
num_chunks++;
}

ASSERT_EQ(5, num_chunks);
}
} // namespace arrow::flight::sql::odbc
Loading