yucheng-du commented on code in PR #1547:
URL: https://github.com/apache/arrow-java/pull/1547#discussion_r4809938881


##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/FlightEndpointDataQueue.java:
##########
@@ -183,7 +183,8 @@ public synchronized void enqueue(final 
CloseableEndpointStreamPair endpointReque
             () -> {
               // `FlightStream#next` will block until new data can be read or 
stream is over.
               while (endpointRequest.getStream().next()) {
-                if (endpointRequest.getStream().getRoot().getRowCount() > 0) {
+                if (endpointRequest.getStream().getLatestMetadata() != null

Review Comment:
   Fixed in 96c0981. The queue now saves the metadata and keeps reading until 
it has rows or reaches EOF. A trailer-only endpoint finishes without handing a 
stream back to the result set.
   
   I reran your six-second delay with a two-second query timeout. 
`executeQuery` timed out after 2.02 s. Adding a second endpoint that 
immediately sent a trailer and finished gave 2.01 s. The new regression holds 
the first row behind a latch after sending progress. It failed on 15adc2e 
because `executeQuery` returned early.
   



##########
flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/ArrowFlightJdbcFlightStreamResultSet.java:
##########
@@ -160,7 +162,14 @@ private void populateData() throws SQLException {
   }
 
   private void populateDataForCurrentFlightStream() throws SQLException {
-    final VectorSchemaRoot originalRoot = 
currentEndpointData.getStream().getRoot();
+    final FlightStream stream = currentEndpointData.getStream();
+    final ArrowBuf metadata = stream.getLatestMetadata();
+    latestBatchMetadata =

Review Comment:
   I took the per-endpoint approach in 96c0981. `getLatestMetadataByEndpoint()` 
returns a copy of each endpoint's last non-null payload in `FlightInfo` order. 
It keeps one value per endpoint, including any trailer when the query is 
exhausted. `getCurrentBatchMetadata()` returns the metadata attached to the 
batch containing the current row.
   
   For example, the test sends two progress messages (43 and 44) between 
batches. The next batch has no metadata. At its first row the batch getter 
returns null and the endpoint entry is 44. At EOF the entries are 99, 98 and 
null for the three endpoints. Callers who need every progress event would still 
need a listener.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to