Fix FlightSQL client to display all batches from multi-partition queries#347
Open
matago wants to merge 1 commit intodatafusion-contrib:mainfrom
Open
Fix FlightSQL client to display all batches from multi-partition queries#347matago wants to merge 1 commit intodatafusion-contrib:mainfrom
matago wants to merge 1 commit intodatafusion-contrib:mainfrom
Conversation
Previously, the FlightSQL client would only display partial results when queries returned multiple batches (common with GROUP BY without ORDER BY due to partitioned execution). This happened because: 1. `run_flightsqls()` only fetched one batch using `match streams.next().await` instead of iterating through all batches 2. `take_record_batches()` only used the first batch when multiple batches existed, ignoring the rest This fix: - Changes `run_flightsqls()` to use `while let` loop to collect all batches from the FlightSQL stream - Updates `take_record_batches()` to concatenate all batches before applying pagination indices, ensuring all rows are visible Known limitations for future consideration: - All batches are collected eagerly into memory before display, which could be problematic for very large result sets - `concat_batches()` creates a temporary copy when concatenating, briefly doubling memory usage during pagination - Unlike the SQL tab which uses lazy batch loading, FlightSQL now loads all data upfront (this matches expected behavior for aggregation queries but may warrant lazy loading for large streaming results in the future) Fixes datafusion-contrib#346
Collaborator
|
Ugh i'm sorry your running into this issue. I confess I'm not a huge fan of this fix as i think it could degrade performance considerably for many other cases to concat everything (in particular on large response sets). But i also clearly want to fix the issue you are having. Im inclined to move forward with this for now and then figure out a more robust pagination solution that would handle this case better (for example maybe concat enough batches to fill a page). |
Collaborator
|
I am working on another fix for this with proper pagination handling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, the FlightSQL client would only display partial results when queries returned multiple batches (common with GROUP BY without ORDER BY due to partitioned execution). This happened because:
run_flightsqls()only fetched one batch usingmatch streams.next().awaitinstead of iterating through all batchestake_record_batches()only used the first batch when multiple batches existed, ignoring the restThis fix:
run_flightsqls()to usewhile letloop to collect all batches from the FlightSQL streamtake_record_batches()to concatenate all batches before applying pagination indices, ensuring all rows are visibleKnown limitations for future consideration:
concat_batches()creates a temporary copy when concatenatingFixes #346