-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-37720: [Format][Docs][FlightSQL] Document stateless prepared statements #40243
GH-37720: [Format][Docs][FlightSQL] Document stateless prepared statements #40243
Conversation
Thanks for opening a pull request! If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project. Then could you also rename the pull request title in the following format?
or
In the case of PARQUET issues on JIRA the title also supports:
See also: |
333b2cb
to
df571f1
Compare
df571f1
to
40c3c21
Compare
…s prepared statements
40c3c21
to
3061d9d
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to discuss backwards compatibility at all? (Presumably it's on the server to detect that the client didn't use the updated handle?)
format/FlightSql.proto
Outdated
option (experimental) = true; | ||
|
||
// (potentially updated) opaque handle for the prepared statement on the server. | ||
// All subsequent requests for his prepared statement must use this new handle, if specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// All subsequent requests for his prepared statement must use this new handle, if specified | |
// All subsequent requests for this prepared statement must use this new handle, if specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to discuss backwards compatibility at all? (Presumably it's on the server to detect that the client didn't use the updated handle?)
The only backwards compatibility safeguard in the current proposal is that the client must assume the returned handle could be missing if the server is following the previous spec. I am open to other suggestions.
What should happen here depends on whether the server is stateful or stateless.
Stateful: This should be inherently backwards and forwards compatible by design. There is no need for an updated handle here, because the server is already managing the necessary state. The server can simply execute the statement with the original handle, or any updated handle, since it should have all the necessary state for the prepared statement.
Stateless: There is no way to properly support prepared statements if the client does not return the updated handle. There is no backwards compatibility here, and so the only thing to do here is to fail gracefully
It may be worthwhile to document this somewhere, but I'm not sure the best place for it.
It would be nice if there could be a way for the server to know whether or not a client supports the updated protocol, as that would provide a more straightforward path for servers to provide graceful failure. But I'm not sure of the best way to do that. There may be implementation-specific tricks involving checking a log or a timestamp embedded in the handle to determine if a handle was updated but I think that's out of the scope of the spec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I think we should have a larger discussion about how to communicate / handle compatibility in the FlightSQL protocol -- I filed #40424 to discuss the over arching issue, so hopefully we can focus discussions on this ticket to this particular proposal
Co-authored-by: David Li <li.davidm96@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much @erratic-pattern - this looks great
Do we need to discuss backwards compatibility at all? (Presumably it's on the server to detect that the client didn't use the updated handle?)
Thank you @lidavidm that is a great idea. I left some potential text for this
This also made me wonder if we do (or should) version the FlightSQL protocol (so for example, we could describe "this client supports version 1.2" or something)
We should wait until a formal vote is held on the mailing list to merge this PR but from my perspective this PR is good to go
format/FlightSql.proto
Outdated
option (experimental) = true; | ||
|
||
// (potentially updated) opaque handle for the prepared statement on the server. | ||
// All subsequent requests for this prepared statement must use this new handle, if specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might help to give a hint here about what this field is used for
// All subsequent requests for this prepared statement must use this new handle, if specified | |
// All subsequent requests for this prepared statement must use this new handle, if specified. | |
// The updated handle allows implementing query parameters with stateless services | |
// as described in https://github.com/apache/arrow/issues/37720 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to copy/summarize the justification here, if we think it's worth keeping, instead of/along with referencing the ticket
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to copy/summarize the justification here, if we think it's worth keeping, instead of/along with referencing the ticket
I've updated the docs to provide some background on this change, as well as explicitly documenting legacy behavior. also made the updated handle explicitly optional
to help indicate that the older stateful pattern should still be supported even in up-to-date clients and servers.
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
b52d0b4
to
0f4d1f4
Compare
docs/source/format/FlightSql.rst
Outdated
The server may optionally respond with an updated handle. The client | ||
should use this updated handle for all subsequent requests for this | ||
prepared statement. The updated handle allows implementing query | ||
parameters with stateless services. Note that the server is responsible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very difficult to understand. How does an updated handle allow implementing query parameters? This should be more descriptive (does the handle embody the bound parameters?).
Also, "the client should use this updated handle" means the client cannot bind the original prepared statement to other parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
. How does an updated handle allow implementing query parameters? This should be more descriptive (does the handle embody the bound parameters?).
Maybe we can say something like this:
Optionally updating the handle allows the client to supply all state required to execute the query in an
ActionPreparedStatementExecute
message. For example, stateless servers can encode the bound parameter values into the new handle, and the client will send that new handle with parameters back to the server.
The problem is as currently written, the CommandPrepareStatementQuery
message contains parameter values, but does not return anything to the client prior to the client sending ActionPreparedStatementExecute
. Thus the only way to implement prepared statements with bind parameters today is to store the value of the parameters on the server between the call to CommandPrepareStatementQuery
and ActionPreparedStatementExecute
.
Also, "the client should use this updated handle" means the client cannot bind the original prepared statement to other parameters?
That is an excellent question. I think the intent is that the handle could be updated with new parameter values. I agree as worded this is confusing and should be clarified
Note that a handle returned from a DoPut call with
CommandPreparedStatementQuery
can itself be passed to a subsequent DoPut call withCommandPreparedStatementQuery
to bind a new set of parameters. The subsequent call itself may return an updated handled which again should be used for subsequent requests.
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the updated changes this PR looks good to me
8ddc3c3
to
4894e23
Compare
…ateless-prepared-statement-params-spec
4894e23
to
b5ad6c5
Compare
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
This proposal was approved on the Arrow dev mailing list. See thread here |
Thank you everyone for your feedback and participation in the process |
After merging your PR, Conbench analyzed the 5 benchmarking runs that have been run so far on merge-commit 2b04275. There were no benchmark performance regressions. 🎉 The full Conbench report has more details. |
…lt (#40311) ### Rationale for this change See discussion on #37720 and mailing list: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq ### What changes are included in this PR? Changes the Go FlightSQL client and server implementations to support returning an updated prepared statement handle to the client as part of the `DoPut(PreparedStatement)` RPC call. ### Are these changes tested? ### Are there any user-facing changes? See parent issue and docs PR #40243 for details of user facing changes. **This PR includes breaking changes to public APIs.** * GitHub Issue: #37720 Lead-authored-by: Adam Curtis <adam.curtis.dev@gmail.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…t result (apache#40311) ### Rationale for this change See discussion on apache#37720 and mailing list: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq ### What changes are included in this PR? Changes the Go FlightSQL client and server implementations to support returning an updated prepared statement handle to the client as part of the `DoPut(PreparedStatement)` RPC call. ### Are these changes tested? ### Are there any user-facing changes? See parent issue and docs PR apache#40243 for details of user facing changes. **This PR includes breaking changes to public APIs.** * GitHub Issue: apache#37720 Lead-authored-by: Adam Curtis <adam.curtis.dev@gmail.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…t result (apache#40311) ### Rationale for this change See discussion on apache#37720 and mailing list: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq ### What changes are included in this PR? Changes the Go FlightSQL client and server implementations to support returning an updated prepared statement handle to the client as part of the `DoPut(PreparedStatement)` RPC call. ### Are these changes tested? ### Are there any user-facing changes? See parent issue and docs PR apache#40243 for details of user facing changes. **This PR includes breaking changes to public APIs.** * GitHub Issue: apache#37720 Lead-authored-by: Adam Curtis <adam.curtis.dev@gmail.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…t result (apache#40311) ### Rationale for this change See discussion on apache#37720 and mailing list: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq ### What changes are included in this PR? Changes the Go FlightSQL client and server implementations to support returning an updated prepared statement handle to the client as part of the `DoPut(PreparedStatement)` RPC call. ### Are these changes tested? ### Are there any user-facing changes? See parent issue and docs PR apache#40243 for details of user facing changes. **This PR includes breaking changes to public APIs.** * GitHub Issue: apache#37720 Lead-authored-by: Adam Curtis <adam.curtis.dev@gmail.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…t result (apache#40311) ### Rationale for this change See discussion on apache#37720 and mailing list: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq ### What changes are included in this PR? Changes the Go FlightSQL client and server implementations to support returning an updated prepared statement handle to the client as part of the `DoPut(PreparedStatement)` RPC call. ### Are these changes tested? ### Are there any user-facing changes? See parent issue and docs PR apache#40243 for details of user facing changes. **This PR includes breaking changes to public APIs.** * GitHub Issue: apache#37720 Lead-authored-by: Adam Curtis <adam.curtis.dev@gmail.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…t result (apache#40311) ### Rationale for this change See discussion on apache#37720 and mailing list: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq ### What changes are included in this PR? Changes the Go FlightSQL client and server implementations to support returning an updated prepared statement handle to the client as part of the `DoPut(PreparedStatement)` RPC call. ### Are these changes tested? ### Are there any user-facing changes? See parent issue and docs PR apache#40243 for details of user facing changes. **This PR includes breaking changes to public APIs.** * GitHub Issue: apache#37720 Lead-authored-by: Adam Curtis <adam.curtis.dev@gmail.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
…t result (apache#40311) ### Rationale for this change See discussion on apache#37720 and mailing list: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq ### What changes are included in this PR? Changes the Go FlightSQL client and server implementations to support returning an updated prepared statement handle to the client as part of the `DoPut(PreparedStatement)` RPC call. ### Are these changes tested? ### Are there any user-facing changes? See parent issue and docs PR apache#40243 for details of user facing changes. **This PR includes breaking changes to public APIs.** * GitHub Issue: apache#37720 Lead-authored-by: Adam Curtis <adam.curtis.dev@gmail.com> Co-authored-by: David Li <li.davidm96@gmail.com> Signed-off-by: David Li <li.davidm96@gmail.com>
documents changes for stateless management of FlightSQL prepared statement handles based on the design proposal described in #37720
PRs for language implementations:
Mailing list discussion: https://lists.apache.org/thread/3kb82ypx99q96g84qv555l6x8r0bppyq