You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "ennuite (via GitHub)" <gi...@apache.org> on 2026/03/27 16:57:38 UTC

[PR] feat(arrow/flight): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

ennuite opened a new pull request, #732:
URL: https://github.com/apache/arrow-go/pull/732

   ### Rationale for this change
   Following the [discussion in the mailing list
   ](https://lists.apache.org/thread/88msflnwkkw8t81czs2ndqhkn1fb1pxd), this PR introduces a new field in `ActionCreatePreparedStatementResult`, `optional boolean is_update`, that allows servers to indicate to clients the correct execution path for prepared statements.
   
   ### What changes are included in this PR?
   
   
   ### Are these changes tested?
   Yes. Unit tests for the new field were added to `client_test.go`, that complement the already existing unit tests for prepared statements queries (there were no tests for prepared statement updates). Integration tests for the new field were added to `server_test.go`. These are also the first integration tests for prepared statements.
   
   ### Are there any user-facing changes?
   Yes. There are no breaking changes because the new field is optional, but a user-facing extension to prepared statements was added to allow for reading/writing to the new field.
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-4754451085

   @ennuite are you still working on this?


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5218750637

   > What is your opinion on s.Require.False() vs s.False()? I haven't found a canonical way to handle these (although I understand in how their behavior differs).
   
   Generally my way of looking at it is pretty much what you describe, whether I find the subsequent tests still interesting/useful if the condition I'm asserting fails. Essentially if I'm testing a condition that if it fails I know that every subsequent assertion in the test will fail, then I just use `Require` so that it bails out early on the first failure. If I just want to assert something but it's still useful for diagnostic (or other test cases) for the test to continue, then I don't use `Require`


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3670708880


##########
arrow/flight/flightsql/client_test.go:
##########
@@ -423,6 +423,123 @@ func (s *FlightSqlClientSuite) TestPreparedStatementExecute() {
 	s.Equal(&emptyFlightInfo, info)
 }
 
+func (s *FlightSqlClientSuite) TestPreparedStatementExecuteWithIsUpdateFalse() {

Review Comment:
   I addressed this in https://github.com/apache/arrow-go/pull/732/changes/eb160883859a2843fdfa2a76598393efac2eb9b1
   
   I do not think it makes sense to have the check in `val`: it being `False` seems like an implementation detail, and not a part of the contract of the `IsUpdate() `method. Let me know if you disagree: I can change it to look exactly like your suggestion.



##########
arrow/flight/flightsql/client.go:
##########
@@ -566,6 +566,7 @@ func (c *Client) LoadPreparedStatementFromResult(result *CreatePreparedStatement
 		handle:        result.PreparedStatementHandle,
 		datasetSchema: dsSchema,
 		paramSchema:   paramSchema,
+		isUpdate:      result.IsUpdate,

Review Comment:
   1. I addressed this with 2 tests. In `TestPreparedStatementLoadFromResult` I let things as they are, and tested with the new field unset, see https://github.com/apache/arrow-go/pull/732/changes/8ba207b4402f60ce27cbad99282eebb8c649e50e.  Note that this test has the same nuance about `val` that I pointed out in https://github.com/apache/arrow-go/pull/732#discussion_r3670708880
   
   I added a new test that checks that the field is properly loaded also when set, see https://github.com/apache/arrow-go/pull/732/changes/a334b86f6c7dbc7e1fc33acc014e5b70b5201e23
   
   2. For that one I purposefully followed the example set by `handle`, but I will admit I had my own reservations while doing it. 
   
   I will not change this in this PR unless you ask me to, but in your opinion is it worth a follow-up PR to have a defensive copy for both `handle` and `isUpdate`? If so I can tackle that after this one
   



##########
arrow/flight/flightsql/server_test.go:
##########
@@ -133,6 +133,74 @@ func (*testServer) DoGetStatement(ctx context.Context, ticket flightsql.Statemen
 	return
 }
 
+func (*testServer) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (result flightsql.ActionCreatePreparedStatementResult, err error) {

Review Comment:
   Addressed this in https://github.com/apache/arrow-go/pull/732/changes/786adc73394a5d1f1987f3c122a6def3d28d1823 
   
   I purposefully do not execute the query: since the hint is not set, it is up to the client to decide whether to execute with `DoGet` or `DoPut`. I do not want the test to misguide someone to think that one way is preferred.
   
   The same nuance about checking `val` when `ok` is `False` is also present in this test (see https://github.com/apache/arrow-go/pull/732#discussion_r3670708880)



##########
arrow/flight/flightsql/server_test.go:
##########
@@ -287,6 +355,69 @@ func (s *FlightSqlServerSuite) TestExecuteChunkError() {
 	}
 }
 
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementQuery() {
+	prep, err := s.cl.Prepare(context.TODO(), "prepared query")
+	s.Require().NoError(err)
+	defer prep.Close(context.TODO())
+
+	val, ok := prep.IsUpdate()
+	s.Require().True(ok)
+	s.False(val)
+
+	fi, err := prep.Execute(context.TODO())
+	s.Require().NoError(err)
+	ep := fi.GetEndpoint()
+	s.Require().Len(ep, 1)
+	fr, err := s.cl.DoGet(context.TODO(), ep[0].GetTicket())
+	s.Require().NoError(err)
+	var recs []arrow.RecordBatch
+	for fr.Next() {
+		rec := fr.RecordBatch()
+		rec.Retain()
+		defer rec.Release()
+		recs = append(recs, rec)
+	}
+	s.Require().NoError(fr.Err())
+	tbl := array.NewTableFromRecords(fr.Schema(), recs)
+	defer tbl.Release()
+	s.Assert().Equal(int64(2), tbl.NumRows())
+	s.Assert().Equal(int64(1), tbl.NumCols())
+	col := tbl.Column(0)
+	s.Assert().Equal("t1", col.Name())
+	s.Assert().Equal(2, col.Len())
+	s.Assert().Equal(1, col.NullN())
+	s.Assert().Equal(arrow.INT16, col.DataType().ID())
+	var n int
+	for _, arr := range col.Data().Chunks() {
+		data := array.NewInt16Data(arr.Data())
+		defer data.Release()
+		for i := 0; i < data.Len(); i++ {
+			switch n {
+			case 0:
+				s.True(data.IsNull(i))
+			case 1:
+				s.False(data.IsNull(i))
+				s.Assert().Equal(int16(1), data.Value(i))
+			}
+			n++
+		}
+	}
+}
+
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementUpdate() {

Review Comment:
   1. About the Substrait path: I added server-side tests at 4816b1b718db17f018f94f57d0f84ab1c64252ff 
   I don't actually execute the queries because, apart from Prepared Statement creation, Substrait and SQL have the exact same execution path in Flight SQL, the difference is only in how the query is sent. Executing the queries would just be exercising the same code path unnecessarily.
   
   I note that I didn't find any client-side tests for Substrait, and I think if we need them then they should go in a separate issue/PR. Do you agree?
   
   2. Yeah, the cleanups outside my own tests were a Find->Replace mistake: I was trying to fix my own tests and did not realize I changed other ones. I'll be more careful next time.



##########
arrow/flight/flightsql/server.go:
##########
@@ -1286,6 +1290,7 @@ func (f *flightSqlServer) DoAction(cmd *flight.Action, stream flight.FlightServi
 		if output.ParameterSchema != nil {
 			result.ParameterSchema = flight.SerializeSchema(output.ParameterSchema, f.mem)
 		}
+		// is_update is not relevant for prepared substrait plans
 

Review Comment:
   Addressed in fcde3da8de20361c11ece62b2ba914d49cfd906f



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-4145019472

   > NB: I'm still investigating what led to such a large diff in the protobuf generated file. The changes correspond only to compiling the PR at https://github.com/apache/arrow/pull/49498 with the following command:
   
   The diff is likely due to the fact that we haven't regenerated the protobuf code for quite a while, and protoc is now several versions ahead of when we last regenerated the code. 
   
   We also have a go generate that'll regenerate for you btw.
   
   I don't consider the diff in the protobuf to necessarily be bad though


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5304110877

   @zeroshade I addressed all comments and rebased. Let me know what you think!


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-4845803763

   @zeroshade Sorry, I will resume work on this now and will address the comments this week.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3670079512


##########
arrow/flight/flightsql/client_test.go:
##########
@@ -423,6 +423,123 @@ func (s *FlightSqlClientSuite) TestPreparedStatementExecute() {
 	s.Equal(&emptyFlightInfo, info)
 }
 
+func (s *FlightSqlClientSuite) TestPreparedStatementExecuteWithIsUpdateFalse() {

Review Comment:
   Do we want the `s.False(val)` check? If `s.False(ok)`, then `val` is meaningless.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790193090


##########
arrow/flight/gen/flight/FlightSql.pb.go:
##########
@@ -17,19 +17,19 @@
 
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.31.0
-// 	protoc        v4.25.3
+// 	protoc-gen-go v1.36.11

Review Comment:
   The first commit is the only one that touches the regenerated proto file: https://github.com/apache/arrow-go/pull/732/changes/09e063c34af39c7f1349859e839aa19802b8bb87
   
   I added the versions to the PR description.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3733066313


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -287,6 +355,69 @@ func (s *FlightSqlServerSuite) TestExecuteChunkError() {
 	}
 }
 
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementQuery() {
+	prep, err := s.cl.Prepare(context.TODO(), "prepared query")
+	s.Require().NoError(err)
+	defer prep.Close(context.TODO())
+
+	val, ok := prep.IsUpdate()
+	s.Require().True(ok)
+	s.False(val)
+
+	fi, err := prep.Execute(context.TODO())
+	s.Require().NoError(err)
+	ep := fi.GetEndpoint()
+	s.Require().Len(ep, 1)
+	fr, err := s.cl.DoGet(context.TODO(), ep[0].GetTicket())
+	s.Require().NoError(err)
+	var recs []arrow.RecordBatch
+	for fr.Next() {
+		rec := fr.RecordBatch()
+		rec.Retain()
+		defer rec.Release()
+		recs = append(recs, rec)
+	}
+	s.Require().NoError(fr.Err())
+	tbl := array.NewTableFromRecords(fr.Schema(), recs)
+	defer tbl.Release()
+	s.Assert().Equal(int64(2), tbl.NumRows())
+	s.Assert().Equal(int64(1), tbl.NumCols())
+	col := tbl.Column(0)
+	s.Assert().Equal("t1", col.Name())
+	s.Assert().Equal(2, col.Len())
+	s.Assert().Equal(1, col.NullN())
+	s.Assert().Equal(arrow.INT16, col.DataType().ID())
+	var n int
+	for _, arr := range col.Data().Chunks() {
+		data := array.NewInt16Data(arr.Data())
+		defer data.Release()
+		for i := 0; i < data.Len(); i++ {
+			switch n {
+			case 0:
+				s.True(data.IsNull(i))
+			case 1:
+				s.False(data.IsNull(i))
+				s.Assert().Equal(int16(1), data.Value(i))
+			}
+			n++
+		}
+	}
+}
+
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementUpdate() {

Review Comment:
   1. About the Substrait path: I added server-side tests at 271a2095410cbd12e232dcc23beb7f680c2338a4 I note that I didn't find any client-side tests for Substrait, and I think if we need them then they should go in a separate issue/PR. Do you agree?
   
   2. Yeah, the cleanups outside my own tests were a Find->Replace mistake: I was trying to fix my own tests and did not realize I changed other ones. I'll be more careful next time.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5243128794

   @ennuite Converting to **draft** — this PR doesn't yet meet our [Pull Request quality criteria](https://github.com/apache/arrow-go/blob/main/CONTRIBUTING.md).
   
   - :x: **Unaddressed Copilot review** — an unresolved review thread from Copilot has been open since 2026-06-08 with no reply ([thread](https://github.com/apache/arrow-go/pull/732#discussion_r3374798100)). See [docs](https://github.com/apache/arrow-go/blob/main/CONTRIBUTING.md).
   
   > **Note:** Your branch is **109 commits behind `main`**. Please rebase and push again to get up-to-date CI results.
   
   See the linked criteria for how to fix each item, then mark the PR "Ready for review". This is **not** a rejection — just an invitation to bring the PR up to standard. No rush.
   
   ---
   
   _Note: This comment was drafted by an AI-assisted triage tool run by a maintainer, and may contain mistakes. Once you have addressed the points above, an Apache Arrow Go maintainer — a real person — will take the next look at your PR. If anything here looks wrong, say so on the PR and a maintainer will follow up. See [CONTRIBUTING.md](https://github.com/apache/arrow-go/blob/main/CONTRIBUTING.md) for the project's contribution conventions._


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3670728243


##########
arrow/flight/flightsql/client.go:
##########
@@ -566,6 +566,7 @@ func (c *Client) LoadPreparedStatementFromResult(result *CreatePreparedStatement
 		handle:        result.PreparedStatementHandle,
 		datasetSchema: dsSchema,
 		paramSchema:   paramSchema,
+		isUpdate:      result.IsUpdate,

Review Comment:
   1. I addressed this with 2 tests. In `TestPreparedStatementLoadFromResult` I let things as they are, and tested with the new field unset, see https://github.com/apache/arrow-go/pull/732/changes/514d3c6d1adbba18eb05faba9bcd313124849556.  Note that this test has the same nuance about `val` that I pointed out in https://github.com/apache/arrow-go/pull/732#discussion_r3670708880
   
   I added a new test that checks that the field is properly loaded also when set, see https://github.com/apache/arrow-go/pull/732/changes/a334b86f6c7dbc7e1fc33acc014e5b70b5201e23
   
   2. For that one I purposefully followed the example set by `handle`, but I will admit I had my own reservations while doing it. 
   
   I will not change this in this PR unless you ask me to, but in your opinion is it worth a follow-up PR to have a defensive copy for both `handle` and `isUpdate`? If so I can tackle that after this one
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3659287031


##########
arrow/flight/flightsql/client.go:
##########
@@ -566,6 +566,7 @@ func (c *Client) LoadPreparedStatementFromResult(result *CreatePreparedStatement
 		handle:        result.PreparedStatementHandle,
 		datasetSchema: dsSchema,
 		paramSchema:   paramSchema,
+		isUpdate:      result.IsUpdate,

Review Comment:
   Two small things on this propagation site.
   
   1. **Untested.** `TestPreparedStatementLoadFromResult` (client_test.go:971) is the only coverage for `LoadPreparedStatementFromResult`, and it doesn't assert `IsUpdate`. Since that test already constructs the result and checks the other two propagated fields (`ParameterSchema`, `DatasetSchema`), adding an `IsUpdate` assertion there would be consistent and nearly free. (Couldn't leave this as an inline comment on that line — it's outside the diff.)
   
   2. **Nit, no change required:** this is the one place that stores a `*bool` owned by the *caller*, so a caller mutating `result.IsUpdate` after this call would change the statement's view. `Prepare`/`PrepareSubstrait` don't have this property since they point at their own unmarshaled local. Not worth a defensive copy unless you'd want it for `handle` too — just noting it so the asymmetry is a conscious choice.



##########
arrow/flight/flightsql/client.go:
##########
@@ -1365,6 +1368,17 @@ func (p *PreparedStatement) DatasetSchema() *arrow.Schema { return p.datasetSche
 // the prepared statement.
 func (p *PreparedStatement) ParameterSchema() *arrow.Schema { return p.paramSchema }
 
+// IsUpdate reports the server's hint for how to execute this prepared statement.
+// val is true if the server indicated an update, false if it indicated a query.
+// ok is false if the server did not provide a hint, in which case the client
+// can choose how to execute the statement.
+func (p *PreparedStatement) IsUpdate() (val bool, ok bool) {

Review Comment:
   **Endorsing this API shape explicitly**, since it has no precedent elsewhere in `arrow/flight` and I'd rather it not get churned in a later review pass.
   
   `(val, ok bool)` is the right call here:
   - It's the direct analogue of the Java client's nullable `Boolean isUpdate()` (guarded by `hasIsUpdate()`), so we're consistent cross-language.
   - Returning `*bool` would hand out internal state and invite mutation; a tri-state enum is overkill for one optional bool.
   - It's plain idiomatic Go (`v, ok := m[k]`).
   
   Also endorsing that this is **informational only** and that `Execute`/`ExecuteUpdate` don't consult it. That matches the spec ("If not set, the client can choose") and mirrors upstream layering: in Java it's the *JDBC adapter* that consumes the hint to pick `StatementType`, not `FlightSqlClient` itself. Our analogous consumer is arrow-adbc, outside this repo. Enforcing or warning on mismatch here would be a behavior change nobody asked for.
   
   The doc comment is clear about all three states. Nice.



##########
arrow/flight/flightsql/client_test.go:
##########
@@ -423,6 +423,123 @@ func (s *FlightSqlClientSuite) TestPreparedStatementExecute() {
 	s.Equal(&emptyFlightInfo, info)
 }
 
+func (s *FlightSqlClientSuite) TestPreparedStatementExecuteWithIsUpdateFalse() {

Review Comment:
   **Please add a test for the unset/`nil` case.** This is my only blocking request.
   
   Both new client tests here, and both new server tests, assert `ok == true`. Nothing anywhere asserts `ok == false`. That's the path taken by every server that doesn't implement the new field — i.e. the backward-compatibility contract — and it's currently the only untested branch of the getter.
   
   `TestPreparedStatementExecute` above (line 368) already builds an `ActionCreatePreparedStatementResult` with no `IsUpdate`, so this can be as small as adding two lines there:
   
   ```go
   val, ok := prepared.IsUpdate()
   s.False(ok)
   s.False(val)
   ```
   
   Worth locking down explicitly because a future refactor that switched `isUpdate *bool` to a plain `bool` would silently turn "no hint" into "is a query" — which is a real behavior change for clients that branch on this — and no existing test would catch it.



##########
arrow/flight/gen/flight/FlightSql.pb.go:
##########
@@ -17,19 +17,19 @@
 
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.31.0
-// 	protoc        v4.25.3
+// 	protoc-gen-go v1.36.11

Review Comment:
   This regeneration jumped the toolchain: `protoc-gen-go v1.31.0 -> v1.36.11` and `protoc v4.25.3 -> v7.34.0`, while the sibling `Flight.pb.go` and `Flight_grpc.pb.go` stay on the old versions. That's what produces the `+765/-1633` diff on a one-field change.
   
   **I am not asking you to revert it, and I want to record that I verified it's safe**, so this doesn't get re-litigated:
   - I diffed every `protobuf:"..."` wire tag, every exported generated method, every generated type, and every enum constant against the true merge-base. The only deltas are the `is_update` tag and `GetIsUpdate()`. Zero other semantic change.
   - Both the old and new files carry the same `protoimpl.EnforceVersion(20 ...)` guards, so this does **not** raise the protobuf runtime floor.
   - `go.mod` already requires `google.golang.org/protobuf v1.36.11`, so the new codegen actually *matches* our pinned runtime — `Flight.pb.go` is the stale one, not this file.
   
   Two requests, both cheap:
   1. Please note the exact `protoc` / `protoc-gen-go` versions you used in the PR description, and if it's not already the case, keep the regeneration as its own commit so the feature commit stays reviewable in isolation.
   2. Please **don't** also regenerate `Flight.pb.go` here — that belongs in a separate cleanup PR.
   
   The root cause isn't yours: `arrow/flight/gen.go` generates from `-I../../../format` (the proto isn't vendored) and we have no CI check that generated files are current, so version drift like this is invited. I'll open a follow-up issue for pinning the generator and adding a regeneration check — no action needed from you.



##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   Not a defect, but this needs a **release note**, because the public API impact is wider than this struct.
   
   `types.go:882` has:
   
   ```go
   type CreatePreparedStatementResult = pb.ActionCreatePreparedStatementResult
   ```
   
   Being a type *alias*, the regenerated proto field lands on a public `flightsql` symbol too. So this PR adds an exported field to two publicly-reachable structs. Keyed composite literals are unaffected (and that's what I found in the downstream usage I spot-checked), but any downstream **unkeyed** literal like:
   
   ```go
   return flightsql.ActionCreatePreparedStatementResult{handle, ds, ps}, nil
   ```
   
   will stop compiling. That's permitted under the Go 1 compatibility rules — unkeyed literals of imported struct types are explicitly not covered — and `go vet`'s `composites` check flags them, so real-world exposure should be low. I don't think it should block the PR, but it's worth a line in the changelog rather than letting someone discover it at upgrade time.
   
   The unconditional `result.IsUpdate = output.IsUpdate` on both the statement and Substrait branches is correct, by the way — both sides are `*bool`, so nil flows through and no presence check is needed. Good that the Substrait path wasn't forgotten.



##########
arrow/flight/flightsql/server_test.go:
##########
@@ -133,6 +133,74 @@ func (*testServer) DoGetStatement(ctx context.Context, ticket flightsql.Statemen
 	return
 }
 
+func (*testServer) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (result flightsql.ActionCreatePreparedStatementResult, err error) {

Review Comment:
   Since you're already switching on the query string here, adding a third case with **no** hint set would give end-to-end coverage of the `ok == false` path through the real server/client round-trip (which is stronger than the mock-level test I asked for in `client_test.go`):
   
   ```go
   case "prepared no hint":
       // leave result.IsUpdate nil - server provides no hint
   ```
   
   Then a short test asserting `IsUpdate()` returns `(false, false)`. Pairs naturally with the two tests you added below.
   
   Thanks for wiring up `CreatePreparedStatement`/`DoGetPreparedStatement`/`DoPutPreparedStatementUpdate` on `testServer` — I confirmed this doesn't disturb the existing `TestDoGet/DoGetPreparedStatement` expectations in the unimplemented-server suite, and the whole `./arrow/flight/...` suite still passes.



##########
arrow/flight/flightsql/server_test.go:
##########
@@ -287,6 +355,69 @@ func (s *FlightSqlServerSuite) TestExecuteChunkError() {
 	}
 }
 
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementQuery() {
+	prep, err := s.cl.Prepare(context.TODO(), "prepared query")
+	s.Require().NoError(err)
+	defer prep.Close(context.TODO())
+
+	val, ok := prep.IsUpdate()
+	s.Require().True(ok)
+	s.False(val)
+
+	fi, err := prep.Execute(context.TODO())
+	s.Require().NoError(err)
+	ep := fi.GetEndpoint()
+	s.Require().Len(ep, 1)
+	fr, err := s.cl.DoGet(context.TODO(), ep[0].GetTicket())
+	s.Require().NoError(err)
+	var recs []arrow.RecordBatch
+	for fr.Next() {
+		rec := fr.RecordBatch()
+		rec.Retain()
+		defer rec.Release()
+		recs = append(recs, rec)
+	}
+	s.Require().NoError(fr.Err())
+	tbl := array.NewTableFromRecords(fr.Schema(), recs)
+	defer tbl.Release()
+	s.Assert().Equal(int64(2), tbl.NumRows())
+	s.Assert().Equal(int64(1), tbl.NumCols())
+	col := tbl.Column(0)
+	s.Assert().Equal("t1", col.Name())
+	s.Assert().Equal(2, col.Len())
+	s.Assert().Equal(1, col.NullN())
+	s.Assert().Equal(arrow.INT16, col.DataType().ID())
+	var n int
+	for _, arr := range col.Data().Chunks() {
+		data := array.NewInt16Data(arr.Data())
+		defer data.Release()
+		for i := 0; i < data.Len(); i++ {
+			switch n {
+			case 0:
+				s.True(data.IsNull(i))
+			case 1:
+				s.False(data.IsNull(i))
+				s.Assert().Equal(int16(1), data.Value(i))
+			}
+			n++
+		}
+	}
+}
+
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementUpdate() {

Review Comment:
   Nit / optional: the Substrait path (`CreatePreparedSubstraitPlan` on the server, `PrepareSubstrait` on the client) also carries the hint now but has no coverage. Residual risk is low since it shares `parsePreparedStatementResponse` with the path you did test, so I wouldn't hold the PR on it — just flagging in case you'd rather close the loop while you're in here.
   
   Separately: the `s.Assert().Equal(true, x)` -> `s.True(x)` cleanups in this file are unrelated to the feature. They're strict improvements so I'm not going to ask you to strip them, but ideally they'd be a separate commit.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790099189


##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   The comment mentions 2 distinct public structs. For clarity, you are asking about release notes for both of them, right? 
   
   I updated the PR description with the breaking change. I looked into how release notes are generated, and it seems like at release time Github will use the PR title in the release notes, but not the description. Given that the description is the place where the breaking change is highlighted, do I need to add release notes elsewhere?
   
    **Explanation of the 2 structs** 
    
    If you agree with my PR description you don't need to read this detail, I leave it for clarity in case I misunderstood your ask.
   
   The type alias refers to `flightsql.CreatePreparedStatementResult`. This is the raw proto version, what goes in the wire, and I think it's there so that users of the `flightsql` package don't need to import the proto package directly. In this codebase, this is only used in `LoadPreparedStatementFromResult()`
   
   But the line about the unkeyed literal is referring to a different struct `flightsql.ActionCreatePreparedStatementResult` that is unrelated to the alias. It is defined in `server.go`, and it is a developer-friendly type with the `*arrow.Schema` objects decoded from wire format. It is used in quite a few places in the codebase.
   
   Both of them fall under the situation of a public struct where unkeyed literals will break, so I put both in the PR description.
   
   Thank you for pointing out the compatibility rules, for reference I found them at https://go.dev/doc/go1compat: 
   
   > For the addition of features in later point releases, it may be necessary to add fields to exported structs in the API. Code that uses unkeyed struct literals (such as pkg.T{3, "x"}) to create values of these types would fail to compile after such a change. However, code that uses keyed literals (pkg.T{A: 3, B: "x"}) will continue to compile after such a change. We will update such data structures in a way that allows keyed struct literals to remain compatible, although unkeyed literals may fail to compile. 
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5304304989

   Addressed all comments and rebased @zeroshade. Let me know what you think!


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790099189


##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   The comment mentions 2 distinct public structs. For clarity, you are asking about release notes for both of them, right? I updated the PR description with the breaking change, let me know if I'm supposed to add it somewhere else.
   
   The type alias refers to `flightsql.CreatePreparedStatementResult`. This is the raw proto version, what goes in the wire, and I think it's there so that users of the `flightsql` package don't need to import the proto package directly. In this codebase, this is only used in `LoadPreparedStatementFromResult()`
   
   But the line about the unkeyed literal is referring to a different struct `flightsql.ActionCreatePreparedStatementResult` that is unrelated to the alias. It is defined in server.go, and it is a developer-friendly type with the *arrow.Schema objects decoded from wire format. It is used in quite a few places in the codebase.
   
   Thank you for pointing out the compatibility rules, for reference I found them at https://go.dev/doc/go1compat: 
   
   > For the addition of features in later point releases, it may be necessary to add fields to exported structs in the API. Code that uses unkeyed struct literals (such as pkg.T{3, "x"}) to create values of these types would fail to compile after such a change. However, code that uses keyed literals (pkg.T{A: 3, B: "x"}) will continue to compile after such a change. We will update such data structures in a way that allows keyed struct literals to remain compatible, although unkeyed literals may fail to compile. 
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3659330630


##########
arrow/flight/gen/flight/FlightSql.pb.go:
##########
@@ -17,19 +17,19 @@
 
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.31.0
-// 	protoc        v4.25.3
+// 	protoc-gen-go v1.36.11

Review Comment:
   Filed the toolchain follow-up as #1029 — pinning the generators, documenting where `format/*.proto` comes from, and adding a CI check that regenerates and fails on diff. Nothing there is asked of this PR; the two requests in this thread still stand as-is (note the versions you used, keep the regen in its own commit).
   
   Also captured there: please **don't** regenerate `Flight.pb.go`/`Flight_grpc.pb.go` here — normalizing all four files is tracked as its own mechanical PR in #1029.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3374798188


##########
arrow/flight/flightsql/client.go:
##########
@@ -1105,13 +1107,14 @@ func (tx *Txn) RollbackSavepoint(ctx context.Context, sp Savepoint, opts ...grpc
 // prepared statement handle.
 //
 // If the server returned the Dataset Schema or Parameter Binding schemas
-// at creation, they will also be accessible from this object. Close
+// or isUpdate at creation, they will also be accessible from this object. Close
 // should be called when no longer needed.

Review Comment:
   The PreparedStatement type doc comment refers to "isUpdate" (lower camel-case) and the sentence is grammatically unclear. Since the exported API is `IsUpdate()` and the concept is a server hint, adjust the wording to clearly describe the new field alongside the existing schema fields.



##########
arrow/flight/flightsql/server_test.go:
##########
@@ -133,6 +133,78 @@ func (*testServer) DoGetStatement(ctx context.Context, ticket flightsql.Statemen
 	return
 }
 
+func (*testServer) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (result flightsql.ActionCreatePreparedStatementResult, err error) {
+	query := req.GetQuery()
+	var isUpdate *bool
+	result.Handle = []byte(query)
+	switch query {
+	case "prepared query":
+		isUpdate := false
+		result.IsUpdate = &isUpdate
+	case "prepared update":
+		isUpdate := true
+		result.IsUpdate = &isUpdate
+	default:
+		err = fmt.Errorf("unknown query: %s", query)
+	}
+	if isUpdate != nil {
+		result.IsUpdate = isUpdate
+	}
+	return

Review Comment:
   In CreatePreparedStatement, `isUpdate` is declared as `*bool` but then shadowed inside the switch (`isUpdate := ...`). This makes the final `if isUpdate != nil { ... }` block dead code and obscures the intent (it never copies a value). Simplify by removing the outer variable and assigning directly to `result.IsUpdate` without shadowing.



##########
arrow/flight/flightsql/server.go:
##########
@@ -1286,6 +1290,7 @@ func (f *flightSqlServer) DoAction(cmd *flight.Action, stream flight.FlightServi
 		if output.ParameterSchema != nil {
 			result.ParameterSchema = flight.SerializeSchema(output.ParameterSchema, f.mem)
 		}
+		// is_update is not relevant for prepared substrait plans
 

Review Comment:
   The CreatePreparedSubstraitPlan action returns `pb.ActionCreatePreparedStatementResult`, which now includes `is_update`. This handler currently drops `output.IsUpdate` (and even states it is not relevant), so servers cannot propagate the hint for prepared Substrait plans even if they set it in `ActionCreatePreparedStatementResult`. Forward `output.IsUpdate` to the protobuf result for consistency with CreatePreparedStatement.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3789997814


##########
arrow/flight/flightsql/server.go:
##########
@@ -1286,6 +1290,7 @@ func (f *flightSqlServer) DoAction(cmd *flight.Action, stream flight.FlightServi
 		if output.ParameterSchema != nil {
 			result.ParameterSchema = flight.SerializeSchema(output.ParameterSchema, f.mem)
 		}
+		// is_update is not relevant for prepared substrait plans
 

Review Comment:
   Addressed in f6a85889fa03deded8844bf71d084c36b90c9044



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790193090


##########
arrow/flight/gen/flight/FlightSql.pb.go:
##########
@@ -17,19 +17,19 @@
 
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.31.0
-// 	protoc        v4.25.3
+// 	protoc-gen-go v1.36.11

Review Comment:
   The first commit is the only one that touches the regenerated proto file: https://github.com/apache/arrow-go/pull/732/changes/09e063c34af39c7f1349859e839aa19802b8bb87 It doesn't touch anything else.
   
   I added the protobuf tools versions to the PR description.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5193356635

   sounds good! Just ping me here when you're ready for another review! feel free to ask any questions if you run into trouble


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3733066313


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -287,6 +355,69 @@ func (s *FlightSqlServerSuite) TestExecuteChunkError() {
 	}
 }
 
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementQuery() {
+	prep, err := s.cl.Prepare(context.TODO(), "prepared query")
+	s.Require().NoError(err)
+	defer prep.Close(context.TODO())
+
+	val, ok := prep.IsUpdate()
+	s.Require().True(ok)
+	s.False(val)
+
+	fi, err := prep.Execute(context.TODO())
+	s.Require().NoError(err)
+	ep := fi.GetEndpoint()
+	s.Require().Len(ep, 1)
+	fr, err := s.cl.DoGet(context.TODO(), ep[0].GetTicket())
+	s.Require().NoError(err)
+	var recs []arrow.RecordBatch
+	for fr.Next() {
+		rec := fr.RecordBatch()
+		rec.Retain()
+		defer rec.Release()
+		recs = append(recs, rec)
+	}
+	s.Require().NoError(fr.Err())
+	tbl := array.NewTableFromRecords(fr.Schema(), recs)
+	defer tbl.Release()
+	s.Assert().Equal(int64(2), tbl.NumRows())
+	s.Assert().Equal(int64(1), tbl.NumCols())
+	col := tbl.Column(0)
+	s.Assert().Equal("t1", col.Name())
+	s.Assert().Equal(2, col.Len())
+	s.Assert().Equal(1, col.NullN())
+	s.Assert().Equal(arrow.INT16, col.DataType().ID())
+	var n int
+	for _, arr := range col.Data().Chunks() {
+		data := array.NewInt16Data(arr.Data())
+		defer data.Release()
+		for i := 0; i < data.Len(); i++ {
+			switch n {
+			case 0:
+				s.True(data.IsNull(i))
+			case 1:
+				s.False(data.IsNull(i))
+				s.Assert().Equal(int16(1), data.Value(i))
+			}
+			n++
+		}
+	}
+}
+
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementUpdate() {

Review Comment:
   1. About the Substrait path: I added server-side tests at 271a2095410cbd12e232dcc23beb7f680c2338a4 
   I don't actually execute the queries because, apart from Prepared Statement creation, Substrait and SQL have the exact same execution path in Flight SQL, the difference is only in how the query is sent. Executing the queries would just be exercising the same code path unnecessarily.
   
   I note that I didn't find any client-side tests for Substrait, and I think if we need them then they should go in a separate issue/PR. Do you agree?
   
   2. Yeah, the cleanups outside my own tests were a Find->Replace mistake: I was trying to fix my own tests and did not realize I changed other ones. I'll be more careful next time.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3675903358


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -133,6 +133,74 @@ func (*testServer) DoGetStatement(ctx context.Context, ticket flightsql.Statemen
 	return
 }
 
+func (*testServer) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (result flightsql.ActionCreatePreparedStatementResult, err error) {

Review Comment:
   Addressed this in https://github.com/apache/arrow-go/pull/732/changes/221f7d6192200dda548ad043bb091e14cf88d754 I purposefully do not execute the query: since the hint is not set, it is up to the client to decide whether to execute with `DoGet` or `DoPut`. I do not want the test to misguide someone to think that one way is preferred.
   
   The same nuance about checking `val` when `ok` is `False` is also present in this test (see https://github.com/apache/arrow-go/pull/732#discussion_r3670708880)



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790099189


##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   The comment mentions 2 distinct public structs. For clarity, you are asking about release notes for both of them, right?
   
   The type alias refers to `flightsql.CreatePreparedStatementResult`. This is the raw proto version, what goes in the wire, and I think it's there so that users of the `flightsql` package don't need to import the proto package directly. In this codebase, this is only used in `LoadPreparedStatementFromResult()`
   
   But the line about the unkeyed literal is referring to a different struct `flightsql.ActionCreatePreparedStatementResult`. It is defined in server.go, and it is a developer-friendly type with the *arrow.Schema objects decoded from wire format. It is used all over the codebase. It is unrelated to the alias.
   
   Thank you for pointing out the compatibility rules, for reference I found them at https://go.dev/doc/go1compat: 
   
   > For the addition of features in later point releases, it may be necessary to add fields to exported structs in the API. Code that uses unkeyed struct literals (such as pkg.T{3, "x"}) to create values of these types would fail to compile after such a change. However, code that uses keyed literals (pkg.T{A: 3, B: "x"}) will continue to compile after such a change. We will update such data structures in a way that allows keyed struct literals to remain compatible, although unkeyed literals may fail to compile. 
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790099189


##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   The comment mentions 2 distinct public structs. For clarity, you are asking about release notes for both of them, right? I updated the PR description with the breaking change, let me know if I'm supposed to add it somewhere else.
   
   The type alias refers to `flightsql.CreatePreparedStatementResult`. This is the raw proto version, what goes in the wire, and I think it's there so that users of the `flightsql` package don't need to import the proto package directly. In this codebase, this is only used in `LoadPreparedStatementFromResult()`
   
   But the line about the unkeyed literal is referring to a different struct `flightsql.ActionCreatePreparedStatementResult` that is unrelated to the alias. It is defined in `server.go`, and it is a developer-friendly type with the `*arrow.Schema` objects decoded from wire format. It is used in quite a few places in the codebase.
   
   Thank you for pointing out the compatibility rules, for reference I found them at https://go.dev/doc/go1compat: 
   
   > For the addition of features in later point releases, it may be necessary to add fields to exported structs in the API. Code that uses unkeyed struct literals (such as pkg.T{3, "x"}) to create values of these types would fail to compile after such a change. However, code that uses keyed literals (pkg.T{A: 3, B: "x"}) will continue to compile after such a change. We will update such data structures in a way that allows keyed struct literals to remain compatible, although unkeyed literals may fail to compile. 
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3797399073


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -287,6 +355,69 @@ func (s *FlightSqlServerSuite) TestExecuteChunkError() {
 	}
 }
 
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementQuery() {
+	prep, err := s.cl.Prepare(context.TODO(), "prepared query")
+	s.Require().NoError(err)
+	defer prep.Close(context.TODO())
+
+	val, ok := prep.IsUpdate()
+	s.Require().True(ok)
+	s.False(val)
+
+	fi, err := prep.Execute(context.TODO())
+	s.Require().NoError(err)
+	ep := fi.GetEndpoint()
+	s.Require().Len(ep, 1)
+	fr, err := s.cl.DoGet(context.TODO(), ep[0].GetTicket())
+	s.Require().NoError(err)
+	var recs []arrow.RecordBatch
+	for fr.Next() {
+		rec := fr.RecordBatch()
+		rec.Retain()
+		defer rec.Release()
+		recs = append(recs, rec)
+	}
+	s.Require().NoError(fr.Err())
+	tbl := array.NewTableFromRecords(fr.Schema(), recs)
+	defer tbl.Release()
+	s.Assert().Equal(int64(2), tbl.NumRows())
+	s.Assert().Equal(int64(1), tbl.NumCols())
+	col := tbl.Column(0)
+	s.Assert().Equal("t1", col.Name())
+	s.Assert().Equal(2, col.Len())
+	s.Assert().Equal(1, col.NullN())
+	s.Assert().Equal(arrow.INT16, col.DataType().ID())
+	var n int
+	for _, arr := range col.Data().Chunks() {
+		data := array.NewInt16Data(arr.Data())
+		defer data.Release()
+		for i := 0; i < data.Len(); i++ {
+			switch n {
+			case 0:
+				s.True(data.IsNull(i))
+			case 1:
+				s.False(data.IsNull(i))
+				s.Assert().Equal(int16(1), data.Value(i))
+			}
+			n++
+		}
+	}
+}
+
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementUpdate() {

Review Comment:
   Yes, a separate issue/PR is fine.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3887902534


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -287,6 +355,69 @@ func (s *FlightSqlServerSuite) TestExecuteChunkError() {
 	}
 }
 
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementQuery() {
+	prep, err := s.cl.Prepare(context.TODO(), "prepared query")
+	s.Require().NoError(err)
+	defer prep.Close(context.TODO())
+
+	val, ok := prep.IsUpdate()
+	s.Require().True(ok)
+	s.False(val)
+
+	fi, err := prep.Execute(context.TODO())
+	s.Require().NoError(err)
+	ep := fi.GetEndpoint()
+	s.Require().Len(ep, 1)
+	fr, err := s.cl.DoGet(context.TODO(), ep[0].GetTicket())
+	s.Require().NoError(err)
+	var recs []arrow.RecordBatch
+	for fr.Next() {
+		rec := fr.RecordBatch()
+		rec.Retain()
+		defer rec.Release()
+		recs = append(recs, rec)
+	}
+	s.Require().NoError(fr.Err())
+	tbl := array.NewTableFromRecords(fr.Schema(), recs)
+	defer tbl.Release()
+	s.Assert().Equal(int64(2), tbl.NumRows())
+	s.Assert().Equal(int64(1), tbl.NumCols())
+	col := tbl.Column(0)
+	s.Assert().Equal("t1", col.Name())
+	s.Assert().Equal(2, col.Len())
+	s.Assert().Equal(1, col.NullN())
+	s.Assert().Equal(arrow.INT16, col.DataType().ID())
+	var n int
+	for _, arr := range col.Data().Chunks() {
+		data := array.NewInt16Data(arr.Data())
+		defer data.Release()
+		for i := 0; i < data.Len(); i++ {
+			switch n {
+			case 0:
+				s.True(data.IsNull(i))
+			case 1:
+				s.False(data.IsNull(i))
+				s.Assert().Equal(int16(1), data.Value(i))
+			}
+			n++
+		}
+	}
+}
+
+func (s *FlightSqlServerSuite) TestExecutePreparedStatementUpdate() {

Review Comment:
   I opened a separate issue at https://github.com/apache/arrow-go/issues/1267 just to make sure it is tracked.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-4144022557

   NB: I'm still investigating what led to such a large diff in the protobuf generated file. The changes correspond only to compiling the PR at https://github.com/apache/arrow/pull/49498 with the following command: 
   ```
   cd /path/to/arrow-go/fork/arrow-go/arrow/flight
   
   protoc --experimental_allow_proto3_optional \
     -I/path/to/arrow/fork/arrow/format \
     --go_out=./gen/flight \
     --go-grpc_out=./gen/flight \
     --go_opt=paths=source_relative \
     --go-grpc_opt=paths=source_relative \
     /path/to/arrow/fork/arrow/format/FlightSql.proto
   ```


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-4651079346

   I rebased this onto main which should solve the CI issues, I'll also re-review it


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790099189


##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   I'm a bit confused because this comment is mixing 2 distinct structs.
   
   The type alias refers to `flightsql.CreatePreparedStatementResult`. This is the raw proto version, what goes in the wire, and I think it's there so that users of the `flightsql` package don't need to import the proto package directly. In this codebase, this is only used in `LoadPreparedStatementFromResult()`
   
   But the line about the unkeyed literal is referring to a different struct `flightsql.ActionCreatePreparedStatementResult`. It is defined in server.go, and it is a developer-friendly type with the *arrow.Schema objects decoded from wire format. It is used all over the codebase. It is unrelated to the alias.
   
   Thank you for pointing out the compatibility rules, for reference I found them at 
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790099189


##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   The comment mentions 2 distinct public structs. For clarity, you are asking about release notes for both of them, right? 
   
   I updated the PR description with the breaking change. I looked into how release notes are generated, and it seems like at release time Github will use the PR title in the release notes, but not the description. Given that the description is the place where the breaking change is highlighted, do I need to add release notes elsewhere?
   
    **Explanation of the 2 structs** 
    
    If you agree with my PR description you don't need to read this detail, I leave it for clarity in case I misunderstood your ask.
   
   The type alias refers to `flightsql.CreatePreparedStatementResult`. This is the raw proto version, what goes in the wire, and I think it's there so that users of the `flightsql` package don't need to import the proto package directly. In this codebase, this is only used in `LoadPreparedStatementFromResult()`
   
   But the line about the unkeyed literal is referring to a different struct `flightsql.ActionCreatePreparedStatementResult` that is unrelated to the alias. It is defined in `server.go`, and it is a developer-friendly type with the `*arrow.Schema` objects decoded from wire format. It is used in quite a few places in the codebase.
   
   Both of them fall under the situation of a public struct where unkeyed literals will break.
   
   Thank you for pointing out the compatibility rules, for reference I found them at https://go.dev/doc/go1compat: 
   
   > For the addition of features in later point releases, it may be necessary to add fields to exported structs in the API. Code that uses unkeyed struct literals (such as pkg.T{3, "x"}) to create values of these types would fail to compile after such a change. However, code that uses keyed literals (pkg.T{A: 3, B: "x"}) will continue to compile after such a change. We will update such data structures in a way that allows keyed struct literals to remain compatible, although unkeyed literals may fail to compile. 
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3517096791


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -133,6 +133,78 @@ func (*testServer) DoGetStatement(ctx context.Context, ticket flightsql.Statemen
 	return
 }
 
+func (*testServer) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (result flightsql.ActionCreatePreparedStatementResult, err error) {
+	query := req.GetQuery()
+	var isUpdate *bool
+	result.Handle = []byte(query)
+	switch query {
+	case "prepared query":
+		isUpdate := false
+		result.IsUpdate = &isUpdate
+	case "prepared update":
+		isUpdate := true
+		result.IsUpdate = &isUpdate
+	default:
+		err = fmt.Errorf("unknown query: %s", query)
+	}
+	if isUpdate != nil {

Review Comment:
   Thank you for this review. 
   Addressed in https://github.com/apache/arrow-go/pull/732/commits/346696955e501cdce0f575f2bd42fda894c621e4



##########
arrow/flight/flightsql/client.go:
##########
@@ -1348,6 +1351,11 @@ func (p *PreparedStatement) DatasetSchema() *arrow.Schema { return p.datasetSche
 // the prepared statement.
 func (p *PreparedStatement) ParameterSchema() *arrow.Schema { return p.paramSchema }
 
+// IsUpdate returns the server's hint about whether this prepared statement
+// should be executed as an update (true) or query (false). If nil, the server
+// did not provide a hint and the client can choose how to execute the statement.
+func (p *PreparedStatement) IsUpdate() *bool { return p.isUpdate }

Review Comment:
   Thank you for pointing this out. I took the idiomatic approach with the double boolean return, see https://github.com/apache/arrow-go/pull/732/changes/2c8c152988cb68a3d622d90bddbd3af962e27901



##########
arrow/flight/flightsql/client.go:
##########
@@ -1105,13 +1107,14 @@ func (tx *Txn) RollbackSavepoint(ctx context.Context, sp Savepoint, opts ...grpc
 // prepared statement handle.
 //
 // If the server returned the Dataset Schema or Parameter Binding schemas
-// at creation, they will also be accessible from this object. Close
+// or isUpdate at creation, they will also be accessible from this object. Close
 // should be called when no longer needed.

Review Comment:
   Addressed in https://github.com/apache/arrow-go/pull/732/changes/028867928ff59e7f4a86eda023b8576f63b0c8c6



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3397696591


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -133,6 +133,78 @@ func (*testServer) DoGetStatement(ctx context.Context, ticket flightsql.Statemen
 	return
 }
 
+func (*testServer) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (result flightsql.ActionCreatePreparedStatementResult, err error) {
+	query := req.GetQuery()
+	var isUpdate *bool
+	result.Handle = []byte(query)
+	switch query {
+	case "prepared query":
+		isUpdate := false
+		result.IsUpdate = &isUpdate
+	case "prepared update":
+		isUpdate := true
+		result.IsUpdate = &isUpdate
+	default:
+		err = fmt.Errorf("unknown query: %s", query)
+	}
+	if isUpdate != nil {

Review Comment:
   The `isUpdate := …` declarations inside the two cases above shadow the outer `var isUpdate *bool`, so this `if isUpdate != nil` always sees nil — it's dead code. The cases already set `result.IsUpdate` directly, so the outer `var isUpdate *bool` and this block can both be removed.



##########
arrow/flight/flightsql/client.go:
##########
@@ -1348,6 +1351,11 @@ func (p *PreparedStatement) DatasetSchema() *arrow.Schema { return p.datasetSche
 // the prepared statement.
 func (p *PreparedStatement) ParameterSchema() *arrow.Schema { return p.paramSchema }
 
+// IsUpdate returns the server's hint about whether this prepared statement
+// should be executed as an update (true) or query (false). If nil, the server
+// did not provide a hint and the client can choose how to execute the statement.
+func (p *PreparedStatement) IsUpdate() *bool { return p.isUpdate }

Review Comment:
   Returning the internal `*bool` leaks mutable state (a caller can do `*ps.IsUpdate() = false` and mutate the statement) and isn't idiomatic for an optional. Prefer `IsUpdate() (val bool, ok bool)`, or return a copy.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3675903358


##########
arrow/flight/flightsql/server_test.go:
##########
@@ -133,6 +133,74 @@ func (*testServer) DoGetStatement(ctx context.Context, ticket flightsql.Statemen
 	return
 }
 
+func (*testServer) CreatePreparedStatement(ctx context.Context, req flightsql.ActionCreatePreparedStatementRequest) (result flightsql.ActionCreatePreparedStatementResult, err error) {

Review Comment:
   Addressed this in https://github.com/apache/arrow-go/pull/732/changes/221f7d6192200dda548ad043bb091e14cf88d754 
   
   I purposefully do not execute the query: since the hint is not set, it is up to the client to decide whether to execute with `DoGet` or `DoPut`. I do not want the test to misguide someone to think that one way is preferred.
   
   The same nuance about checking `val` when `ok` is `False` is also present in this test (see https://github.com/apache/arrow-go/pull/732#discussion_r3670708880)



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3670728243


##########
arrow/flight/flightsql/client.go:
##########
@@ -566,6 +566,7 @@ func (c *Client) LoadPreparedStatementFromResult(result *CreatePreparedStatement
 		handle:        result.PreparedStatementHandle,
 		datasetSchema: dsSchema,
 		paramSchema:   paramSchema,
+		isUpdate:      result.IsUpdate,

Review Comment:
   1. I addressed this with 2 tests. In `TestPreparedStatementLoadFromResult` I let things as they are, and tested with the new field unset, see https://github.com/apache/arrow-go/pull/732/changes/514d3c6d1adbba18eb05faba9bcd313124849556.  Note that this test has the same about `val` that I pointed out in https://github.com/apache/arrow-go/pull/732#discussion_r3670708880
   
   I added a new test that checks that the field is properly loaded also when set, see https://github.com/apache/arrow-go/pull/732/changes/a334b86f6c7dbc7e1fc33acc014e5b70b5201e23
   
   2. For that one I purposefully followed the example set by `handle`, but I will admit I had my own reservations while doing it. 
   
   I will not change this in this PR unless you ask me to, but in your opinion is it worth a follow-up PR to have a defensive copy for both `handle` and `isUpdate`? If so I can tackle that after this one
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5111460665

   Thanks for the very thorough review! 
   
   I'm going over the comments one by one, I might be a bit slow as I'm ramping up on some of the Go concepts, and your feedback has been a great learning experience.
   
   I appreciate your patience as I improve the PR.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3670708880


##########
arrow/flight/flightsql/client_test.go:
##########
@@ -423,6 +423,123 @@ func (s *FlightSqlClientSuite) TestPreparedStatementExecute() {
 	s.Equal(&emptyFlightInfo, info)
 }
 
+func (s *FlightSqlClientSuite) TestPreparedStatementExecuteWithIsUpdateFalse() {

Review Comment:
   I addressed this in https://github.com/apache/arrow-go/pull/732/changes/a324e276df3cc4727fe6d9befaca6aef76d0b838
   
   I do not think it makes sense to have the check in `val`: it being `False` seems like an implementation detail, and not a part of the contract of the `IsUpdate() `method. Let me know if you disagree: I can change it to look exactly like your suggestion.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3567587321


##########
arrow/flight/flightsql/client.go:
##########
@@ -1105,13 +1107,14 @@ func (tx *Txn) RollbackSavepoint(ctx context.Context, sp Savepoint, opts ...grpc
 // prepared statement handle.
 //
 // If the server returned the Dataset Schema or Parameter Binding schemas
-// at creation, they will also be accessible from this object. Close
+// or isUpdate at creation, they will also be accessible from this object. Close
 // should be called when no longer needed.

Review Comment:
   Addressed in https://github.com/apache/arrow-go/pull/732/changes/fcecddd10018d3c7c8b0c449a1cd87ef9a9f02ed



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5211658281

   Still not ready for a review as I still need to look into the protobuf stuff and the release notes, but a question popped in my mind (which is probably nitpicky).
   
   What is your opinion on `s.Require.False(`) vs `s.False()`? I haven't found a canonical way to handle these (although I understand in how their behavior differs).
   
   For the server tests, I'm always using `Require()` for every check of values returned by `PreparedStatement.IsUpdate()`, because the code after those checks (if there is any) just execute the query, and without proper values returned by IsUpdate we don't know how to properly execute the query (DoPut vs DoGet)
   
   For the client tests:
   
   1. In my new tests (`TestPreparedStatementExecuteWithIsUpdateFalse` and `TestPreparedStatementExecuteUpdateWithIsUpdateTrue`) I also use `Require()` using the same logic as above. 
   2. For `TestPreparedStatementLoadFromResultWithIsUpdate`: given that we are just testing the loading and not execution, it would be interesting to see if `ok` was loaded incorrectly and `val` correctly, so I don't use `Require()`
   3. For the pre-existing tests I don't use `Require` because there are interesting things to test even if these fields are broken (the tests were not created solely for this feature).
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "ennuite (via GitHub)" <gi...@apache.org>.
ennuite commented on code in PR #732:
URL: https://github.com/apache/arrow-go/pull/732#discussion_r3790099189


##########
arrow/flight/flightsql/server.go:
##########
@@ -155,6 +155,9 @@ type ActionCreatePreparedStatementResult struct {
 	Handle          []byte
 	DatasetSchema   *arrow.Schema
 	ParameterSchema *arrow.Schema
+	// IsUpdate indicates whether the prepared statement should be executed
+	// as an update (true) or query (false). If nil, the client can choose.
+	IsUpdate *bool

Review Comment:
   The comment mentions 2 distinct public structs. For clarity, you are asking about release notes for both of them, right? I updated the PR description with the breaking change, let me know if I'm supposed to add it somewhere else.
   
   The type alias refers to `flightsql.CreatePreparedStatementResult`. This is the raw proto version, what goes in the wire, and I think it's there so that users of the `flightsql` package don't need to import the proto package directly. In this codebase, this is only used in `LoadPreparedStatementFromResult()`
   
   But the line about the unkeyed literal is referring to a different struct `flightsql.ActionCreatePreparedStatementResult`. It is defined in server.go, and it is a developer-friendly type with the *arrow.Schema objects decoded from wire format. It is used all over the codebase. It is unrelated to the alias.
   
   Thank you for pointing out the compatibility rules, for reference I found them at https://go.dev/doc/go1compat: 
   
   > For the addition of features in later point releases, it may be necessary to add fields to exported structs in the API. Code that uses unkeyed struct literals (such as pkg.T{3, "x"}) to create values of these types would fail to compile after such a change. However, code that uses keyed literals (pkg.T{A: 3, B: "x"}) will continue to compile after such a change. We will update such data structures in a way that allows keyed struct literals to remain compatible, although unkeyed literals may fail to compile. 
   
   



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade merged PR #732:
URL: https://github.com/apache/arrow-go/pull/732


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat(arrow/flight/sql): Add is_update field to ActionCreatePreparedStatementResult [arrow-go]

Posted by "zeroshade (via GitHub)" <gi...@apache.org>.
zeroshade commented on PR #732:
URL: https://github.com/apache/arrow-go/pull/732#issuecomment-5218826168

   > What is your opinion on s.Require.False() vs s.False()? I haven't found a canonical way to handle these (although I understand in how their behavior differs).
   
   Generally my way of looking at it is pretty much what you describe, whether I find the subsequent tests still interesting/useful if the condition I'm asserting fails. Essentially if I'm testing a condition that if it fails I know that every subsequent assertion in the test will fail, then I just use `Require` so that it bails out early on the first failure. If I just want to assert something but it's still useful for diagnostic (or other test cases) for the test to continue, then I don't use `Require`


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org