feat(sql): run a statement in one round trip with execute_query - #4169
Draft
jackye1995 wants to merge 1 commit into
Draft
feat(sql): run a statement in one round trip with execute_query#4169jackye1995 wants to merge 1 commit into
jackye1995 wants to merge 1 commit into
Conversation
`execute_query_async` was the only way to run SQL, and it always submits then fetches: `PollFlightInfo` so the client learns a ticket encoding and a schema, then `DoGet` to read the rows. `SELECT 1` paid two round trips and two server plans for a handle it never polled, never cancelled, and read once. `execute_query` sends the statement as the ticket and streams the answer back on the same call. The encoding is nothing the client needed to be told, and the schema arrives as the stream's first message rather than in an earlier reply. The async path is unchanged and is still the right one for a large or slow answer: it can be polled, cancelled, read from several endpoints at once, and it survives the client leaving. The new call is the one to reach for otherwise, and the docs on each now say which is which. Servers that do not read a raw ticket as a statement are unaffected -- they never see one unless a caller asks for it by using this method.
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.
execute_query_asyncis currently the only way to run SQL, and it always submits then fetches —PollFlightInfoso the client learns a ticket encoding and a schema, thenDoGetto read the rows.SELECT 1pays two round trips and two server plans for a handle it never polls, never cancels, and reads once.Connection::execute_querysends the statement as the ticket and streams the answer on the same call:Neither thing the extra round trip was buying is needed. The ticket encoding is nothing the client has to be told, and a
DoGetstream carries its schema in its first message rather than in an earlier reply. This is the same shape ClickHouse's Arrow Flight server accepts, whereDoGettakes "a raw SQL query string as the ticket value".Which to use
execute_queryexecute_query_asyncThe async path is unchanged and stays the right tool for a large or slow answer. The new call is the one to reach for otherwise, and the doc comments on each now say so.
Compatibility
Additive. A server that does not read a raw ticket as a statement never sees one unless a caller asks for it by name.
Tests
PollFlightInfocalls with exactly oneDoGet— the counters are the real assertion, since a reintroduced planning round trip would still return correct rows.