This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 2f89cf5bb36 GH-54649: [C++][FlightRPC][ODBC] Fetch on the current
connection for arrow-flight-reuse-connection locations (#54652)
2f89cf5bb36 is described below
commit 2f89cf5bb36933aaf43ed3824be32244f9f14300
Author: Abhishek Pathania <[email protected]>
AuthorDate: Thu Nov 5 08:41:33 2026 +0530
GH-54649: [C++][FlightRPC][ODBC] Fetch on the current connection for
arrow-flight-reuse-connection locations (#54652)
### Rationale for this change
Flight servers can return `arrow-flight-reuse-connection://?` as an
endpoint location (GH-40345) to mean "fetch on the current connection". The
ODBC driver passes it to `FlightClient::Connect`, which fails with "No client
transport implementation for arrow-flight-reuse-connection". Result sets and
`SQLGetInfo`, including the DSN dialog's Test Connection, fail against such
servers.
### What changes are included in this PR?
`FlightStreamChunkBuffer` treats an endpoint whose first location uses the
reuse-connection scheme the same as an endpoint with no locations, and calls
`DoGet` on the existing client. The JDBC driver handles it the same way.
### Are these changes tested?
Yes. `FlightStreamChunkBufferTest.TestReuseConnectionLocation` fails
without the fix.
### Are there any user-facing changes?
The ODBC driver can read results from servers that return the
reuse-connection location.
### Was AI used for this PR?
**PR code and description written by:**
- [ ] Human
- [x] AI
**Reviewed before submission by:**
- [x] Human
- [ ] AI
- [ ] Not reviewed
* GitHub Issue: #54649
Authored-by: AbhishekPathania <[email protected]>
Signed-off-by: David Li <[email protected]>
---
.../odbc_impl/flight_sql_stream_chunk_buffer.cc | 8 ++++----
.../flight_sql_stream_chunk_buffer_test.cc | 23 ++++++++++++++++++++++
2 files changed, 27 insertions(+), 4 deletions(-)
diff --git
a/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer.cc
b/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer.cc
index be788d9d08a..45c5f3a9126 100644
--- a/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer.cc
+++ b/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer.cc
@@ -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
@@ -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(
diff --git
a/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer_test.cc
b/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer_test.cc
index cbe5cd8f7e5..79f20cd8c4a 100644
---
a/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer_test.cc
+++
b/cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_stream_chunk_buffer_test.cc
@@ -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(¤t_chunk)) {
+ num_chunks++;
+ }
+
+ ASSERT_EQ(5, num_chunks);
+}
} // namespace arrow::flight::sql::odbc