Skip to content
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

Conversation

erratic-pattern
Copy link
Contributor

@erratic-pattern erratic-pattern commented Feb 26, 2024

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

Copy link

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?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

In the case of PARQUET issues on JIRA the title also supports:

PARQUET-${JIRA_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

See also:

@erratic-pattern erratic-pattern changed the title feat(flightsql): update spec to support stateless prepared statements doc(flightsql): document stateless prepared statements Feb 26, 2024
@erratic-pattern erratic-pattern force-pushed the adam/flightsql/stateless-prepared-statement-params-spec branch from 333b2cb to df571f1 Compare February 26, 2024 16:31
@erratic-pattern erratic-pattern force-pushed the adam/flightsql/stateless-prepared-statement-params-spec branch from df571f1 to 40c3c21 Compare March 1, 2024 19:16
@erratic-pattern erratic-pattern force-pushed the adam/flightsql/stateless-prepared-statement-params-spec branch from 40c3c21 to 3061d9d Compare March 1, 2024 19:22
@erratic-pattern erratic-pattern changed the title doc(flightsql): document stateless prepared statements GH-37720: [Go][FlightSQL] Implement stateless prepared statements Mar 1, 2024
@erratic-pattern erratic-pattern changed the title GH-37720: [Go][FlightSQL] Implement stateless prepared statements GH-37720: [Format][Docs][FlightSQL] Document FlightSQL stateless prepared statements Mar 1, 2024
Copy link

github-actions bot commented Mar 1, 2024

⚠️ GitHub issue #37720 has been automatically assigned in GitHub to PR creator.

@erratic-pattern erratic-pattern changed the title GH-37720: [Format][Docs][FlightSQL] Document FlightSQL stateless prepared statements GH-37720: [Format][Docs][FlightSQL] Document stateless prepared statements Mar 1, 2024
Copy link
Member

@lidavidm lidavidm left a 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?)

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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

Copy link
Contributor Author

@erratic-pattern erratic-pattern Mar 2, 2024

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

Copy link
Contributor

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

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting review Awaiting review labels Mar 2, 2024
Co-authored-by: David Li <li.davidm96@gmail.com>
Copy link
Contributor

@alamb alamb left a 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

docs/source/format/FlightSql.rst Outdated Show resolved Hide resolved
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
Copy link
Contributor

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

Suggested change
// 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

Copy link
Member

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

Copy link
Contributor Author

@erratic-pattern erratic-pattern Mar 4, 2024

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.

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting merge Awaiting merge labels Mar 4, 2024
Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Mar 4, 2024
erratic-pattern and others added 2 commits March 4, 2024 09:55
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
Copy link
Member

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?

Copy link
Contributor

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 with CommandPreparedStatementQuery to bind a new set of parameters. The subsequent call itself may return an updated handled which again should be used for subsequent requests.

@github-actions github-actions bot added the awaiting change review Awaiting change review label Mar 16, 2024
Copy link
Contributor

@alamb alamb left a 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

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Mar 18, 2024
@erratic-pattern erratic-pattern force-pushed the adam/flightsql/stateless-prepared-statement-params-spec branch from 8ddc3c3 to 4894e23 Compare March 20, 2024 00:59
@erratic-pattern erratic-pattern force-pushed the adam/flightsql/stateless-prepared-statement-params-spec branch from 4894e23 to b5ad6c5 Compare March 20, 2024 01:22
@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting merge Awaiting merge labels Mar 22, 2024
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Mar 22, 2024
@erratic-pattern erratic-pattern marked this pull request as ready for review March 24, 2024 17:06
@erratic-pattern
Copy link
Contributor Author

This proposal was approved on the Arrow dev mailing list. See thread here

@alamb alamb merged commit 2b04275 into apache:main Mar 25, 2024
8 checks passed
@alamb
Copy link
Contributor

alamb commented Mar 25, 2024

Thank you everyone for your feedback and participation in the process

Copy link

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.

lidavidm added a commit that referenced this pull request Apr 23, 2024
…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>
zanmato1984 pushed a commit to zanmato1984/arrow that referenced this pull request Apr 24, 2024
…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>
tolleybot pushed a commit to tmct/arrow that referenced this pull request May 2, 2024
…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>
tolleybot pushed a commit to tmct/arrow that referenced this pull request May 4, 2024
…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>
rok pushed a commit to tmct/arrow that referenced this pull request May 8, 2024
…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>
rok pushed a commit to tmct/arrow that referenced this pull request May 8, 2024
…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>
vibhatha pushed a commit to vibhatha/arrow that referenced this pull request May 25, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants