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

feat: Implement ExecuteQuery API for SQL support #2280

Merged
merged 18 commits into from
Jul 17, 2024

Conversation

jackdingilian
Copy link
Contributor

@jackdingilian jackdingilian commented Jul 11, 2024

This adds the executeQuery method to the data client in order to support querying data using SQL.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Rollback plan is reviewed and LGTMed
  • All new data plane features have a completed end to end testing plan

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the samples format.

@jackdingilian jackdingilian requested review from a team as code owners July 11, 2024 20:21
@product-auto-label product-auto-label bot added the size: xl Pull request size is extra large. label Jul 11, 2024
Copy link

Warning: This pull request is touching the following templated files:

  • google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/gapic_metadata.json
  • google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStub.java
  • google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableStubSettings.java
  • google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/GrpcBigtableStub.java
  • grpc-google-cloud-bigtable-v2/src/main/java/com/google/bigtable/v2/BigtableGrpc.java
  • proto-google-cloud-bigtable-v2/src/main/java/com/google/bigtable/v2/BigtableProto.java
  • proto-google-cloud-bigtable-v2/src/main/java/com/google/bigtable/v2/DataProto.java
  • proto-google-cloud-bigtable-v2/src/main/proto/google/bigtable/v2/bigtable.proto
  • proto-google-cloud-bigtable-v2/src/main/proto/google/bigtable/v2/data.proto

@product-auto-label product-auto-label bot added the api: bigtable Issues related to the googleapis/java-bigtable API. label Jul 11, 2024
@jackdingilian
Copy link
Contributor Author

cc @igorbernstein2 for awareness

@jackdingilian
Copy link
Contributor Author

/gcbrun

@steveniemitz
Copy link
Contributor

/gcbrun

@steveniemitz steveniemitz added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 12, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 12, 2024
@steveniemitz
Copy link
Contributor

/gcbrun

3 similar comments
@steveniemitz
Copy link
Contributor

/gcbrun

@jackdingilian
Copy link
Contributor Author

/gcbrun

@jackdingilian
Copy link
Contributor Author

/gcbrun

gcf-owl-bot bot and others added 14 commits July 16, 2024 15:38
The ExecuteQuery API will allow users to query Bigtable using SQL

PiperOrigin-RevId: 650660213

Source-Link: googleapis/googleapis@f681f79

Source-Link: googleapis/googleapis-gen@3180845
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzE4MDg0NTQ4NzEzNjc5NDk1MmI4ZjM2NWZlNmM2ODY4OTk5ZDljMCJ9
This is needed to parse ExecuteQuery responses

PiperOrigin-RevId: 651386373

Source-Link: googleapis/googleapis@a5be6fa

Source-Link: googleapis/googleapis-gen@d467ce8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDQ2N2NlODkzYTA0YzQxZTUwNDk4MzM0NmMyMTVkNDFmZDI2MzY1MCJ9
I will re-add these once the client supports the appropriate behavior for readRows

Change-Id: I4b5b0861e93f0a8b97d51556c74bccfe0b1da521
This moves things mostly as is. I will move everything to appropriate packages in a follow on (e.g. utils will move to internal). Wanted to keep the changes as minimal as possible

Renames ProtoRowsBatchMergingStateMachine to ProtoRowsMergingStateMachine and removes the obsolete ProtoRowsMergingStateMachine

This simplifies the internal code by removing support for the old api. It should not change any behavior for he ProtoRowsBatch API

Change-Id: I8e8267a9cfeb59e0f8455876d1bccdb7c3778b76
This adds the main interfaces for interacting with data:
ResultSet, StructReader, and Struct. StructReader is used
by ResultSet, SqlRow, and Struct to provide a standard set
of accessors for the data.

I'm a little uncertain about the package structure right
now. I've put interfaces that users will interact with
directly in 'models' and everything else in 'internal'.
Internal will include both internal interfaces and the
implementations of the public interfaces. Otherwise I have
kept the package structure pretty flat but happy to group
the sql stuff together more.

This includes thorough documentation for the public interfaces.

Change-Id: I4535daffc596e9355da64b5655c58a68e5e7a95f
This will be re-used for structs in the following commit. The current
design implements this at the Row/Struct level instead of ResultSet &
Struct so that result set can operate on rows of different types when we
support arrow. ResultSet will then be a light wrapper where each getType
call is passed through to the current row.

Change-Id: I21fb4cc0cd830110d5455581491c5b1861efbcb1
Change-Id: Ie9d3892fe92c779a6b81d457c31b534bdce20f38
This also removes the metadata helpers from the ResultSet interface.
These helpers will live on ResultSetMetadata instead.

Change-Id: Iba60b42b4e62f2d72c5a21206edf716c0ad5ea73
Also fix AbstractProtoStructReaderTest which was using the wrong runner
and not executing any tests. Fixes a couple test bugs as well.

Change-Id: Ia59459f93dd38046e9ac22995191becaad6ea44e
This uses the ExecuteQueryCallContext to pass the metadata back
to the user using a future. Note that we need to be very careful
here that errors always close this future. That is why watchdog
happens higher in the call chain that for other streaming RPCs

Also note i decided to unwrap executeExceptions so that when
possible the future throws the same exceptions as the row stream

Change-Id: Ie9dd523a980efecb2cff010a2ffd7ac52b5f8ac7
Change-Id: Id9113adb24419da18f6e43e47c0c73cddf4b622e
The admin types in admin.v2.models.Type will be migrated to
1) share the same implementation in common, while defining a
narrow interface like SqlType 2) be renamed to SchemaType.
We aren't going to block the Sql launch on this though. It
can happen after.

Change-Id: I9dea84fe9b7b2e0b46e8ece4cb666651183dc639
Change-Id: I41a28069865df6aa688ac5bc96181aae9f18deb4
Change-Id: I0cf3bd45a5f2bb3e2ad980d4170049d69e701d7e
Change-Id: Ie08217d025df3ec3c97dc96268f1c4e1d20b33bf
Change-Id: I6073e41b5a5b74b91671002cb93dc42c4023f10f
@jackdingilian jackdingilian added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Jul 16, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 16, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 16, 2024
@jackdingilian jackdingilian added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 16, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 16, 2024
@jackdingilian jackdingilian added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 16, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jul 16, 2024
@jackdingilian jackdingilian merged commit 25218e8 into googleapis:main Jul 17, 2024
21 checks passed
ron-gal pushed a commit to ron-gal/java-bigtable that referenced this pull request Jul 23, 2024
* feat: publish the Cloud Bigtable ExecuteQuery API

The ExecuteQuery API will allow users to query Bigtable using SQL

PiperOrigin-RevId: 650660213

Source-Link: googleapis/googleapis@f681f79

Source-Link: googleapis/googleapis-gen@3180845
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzE4MDg0NTQ4NzEzNjc5NDk1MmI4ZjM2NWZlNmM2ODY4OTk5ZDljMCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: publish ProtoRows Message

This is needed to parse ExecuteQuery responses

PiperOrigin-RevId: 651386373

Source-Link: googleapis/googleapis@a5be6fa

Source-Link: googleapis/googleapis-gen@d467ce8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDQ2N2NlODkzYTA0YzQxZTUwNDk4MzM0NmMyMTVkNDFmZDI2MzY1MCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Temporarily allow method level tests to pass for ExecuteQuery

I will re-add these once the client supports the appropriate behavior for readRows

Change-Id: I4b5b0861e93f0a8b97d51556c74bccfe0b1da521

* Copy SqlRowMerger from internal code

This moves things mostly as is. I will move everything to appropriate packages in a follow on (e.g. utils will move to internal). Wanted to keep the changes as minimal as possible

Renames ProtoRowsBatchMergingStateMachine to ProtoRowsMergingStateMachine and removes the obsolete ProtoRowsMergingStateMachine

This simplifies the internal code by removing support for the old api. It should not change any behavior for he ProtoRowsBatch API

Change-Id: I8e8267a9cfeb59e0f8455876d1bccdb7c3778b76

* Implement main interfaces for interacting with ResultSets

This adds the main interfaces for interacting with data:
ResultSet, StructReader, and Struct. StructReader is used
by ResultSet, SqlRow, and Struct to provide a standard set
of accessors for the data.

I'm a little uncertain about the package structure right
now. I've put interfaces that users will interact with
directly in 'models' and everything else in 'internal'.
Internal will include both internal interfaces and the
implementations of the public interfaces. Otherwise I have
kept the package structure pretty flat but happy to group
the sql stuff together more.

This includes thorough documentation for the public interfaces.

Change-Id: I4535daffc596e9355da64b5655c58a68e5e7a95f

* Implement proto to java conversion via AbstractProtoStructReader

This will be re-used for structs in the following commit. The current
design implements this at the Row/Struct level instead of ResultSet &
Struct so that result set can operate on rows of different types when we
support arrow. ResultSet will then be a light wrapper where each getType
call is passed through to the current row.

Change-Id: I21fb4cc0cd830110d5455581491c5b1861efbcb1

* Add implementation for ProtoStruct

Change-Id: Ie9d3892fe92c779a6b81d457c31b534bdce20f38

* Implement ResultSet

This also removes the metadata helpers from the ResultSet interface.
These helpers will live on ResultSetMetadata instead.

Change-Id: Iba60b42b4e62f2d72c5a21206edf716c0ad5ea73

* Implement ResultSetMetadata and use it everwhere we operate on metadata

Also fix AbstractProtoStructReaderTest which was using the wrong runner
and not executing any tests. Fixes a couple test bugs as well.

Change-Id: Ia59459f93dd38046e9ac22995191becaad6ea44e

* Create execute query callables and wire up api to data client

This uses the ExecuteQueryCallContext to pass the metadata back
to the user using a future. Note that we need to be very careful
here that errors always close this future. That is why watchdog
happens higher in the call chain that for other streaming RPCs

Also note i decided to unwrap executeExceptions so that when
possible the future throws the same exceptions as the row stream

Change-Id: Ie9dd523a980efecb2cff010a2ffd7ac52b5f8ac7

* Add statement API for ExecuteQuery requests

Change-Id: Id9113adb24419da18f6e43e47c0c73cddf4b622e

* Implement java representation of Type protobuf

The admin types in admin.v2.models.Type will be migrated to
1) share the same implementation in common, while defining a
narrow interface like SqlType 2) be renamed to SchemaType.
We aren't going to block the Sql launch on this though. It
can happen after.

Change-Id: I9dea84fe9b7b2e0b46e8ece4cb666651183dc639

* Remove unsupported query param types and add doc

Change-Id: I41a28069865df6aa688ac5bc96181aae9f18deb4

* Add clirr exclusion for new proto method. Fix dropped import

Change-Id: I0cf3bd45a5f2bb3e2ad980d4170049d69e701d7e

* Small doc update and remove obsolete TODOs

Change-Id: Ie08217d025df3ec3c97dc96268f1c4e1d20b33bf

* Minor documentation fix for executeQuery

Change-Id: I6073e41b5a5b74b91671002cb93dc42c4023f10f

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
gcf-merge-on-green bot pushed a commit that referenced this pull request Jul 24, 2024
🤖 I have created a release *beep* *boop*
---


## [2.41.0](https://github.com/googleapis/java-bigtable/compare/v2.40.0...v2.41.0) (2024-07-24)


### Features

* Add MergeToCell to Mutation APIs ([#2279](https://github.com/googleapis/java-bigtable/issues/2279)) ([0ce8a2a](https://github.com/googleapis/java-bigtable/commit/0ce8a2a38703233da58208655f41f6e81e03576e))
* Add support for MergeToCell API ([#2258](https://github.com/googleapis/java-bigtable/issues/2258)) ([191d15c](https://github.com/googleapis/java-bigtable/commit/191d15c5284dbb702e11669931272877bf05f44e))
* Add support for new functions ([#2287](https://github.com/googleapis/java-bigtable/issues/2287)) ([dd6583a](https://github.com/googleapis/java-bigtable/commit/dd6583a22504385b7a1f7dc91b3bc3d2500ea0c5))
* Create new environment variable to toggle directpath scoped to cloud bigtable. ([#2261](https://github.com/googleapis/java-bigtable/issues/2261)) ([9062944](https://github.com/googleapis/java-bigtable/commit/9062944610277eb7ae77f395dc79ce94239c5bee))
* Implement ExecuteQuery API for SQL support ([#2280](https://github.com/googleapis/java-bigtable/issues/2280)) ([25218e8](https://github.com/googleapis/java-bigtable/commit/25218e8cc46f9a51d4b6515afdb8931e574b0bb1))


### Dependencies

* Update dependency com.google.truth.extensions:truth-proto-extension to v1.4.4 ([#2282](https://github.com/googleapis/java-bigtable/issues/2282)) ([d00a9e0](https://github.com/googleapis/java-bigtable/commit/d00a9e01b2b329f3bae50f48a15692d87ad0f3bf))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
lqiu96 pushed a commit that referenced this pull request Jul 26, 2024
* feat: publish the Cloud Bigtable ExecuteQuery API

The ExecuteQuery API will allow users to query Bigtable using SQL

PiperOrigin-RevId: 650660213

Source-Link: googleapis/googleapis@f681f79

Source-Link: googleapis/googleapis-gen@3180845
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzE4MDg0NTQ4NzEzNjc5NDk1MmI4ZjM2NWZlNmM2ODY4OTk5ZDljMCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: publish ProtoRows Message

This is needed to parse ExecuteQuery responses

PiperOrigin-RevId: 651386373

Source-Link: googleapis/googleapis@a5be6fa

Source-Link: googleapis/googleapis-gen@d467ce8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZDQ2N2NlODkzYTA0YzQxZTUwNDk4MzM0NmMyMTVkNDFmZDI2MzY1MCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* Temporarily allow method level tests to pass for ExecuteQuery

I will re-add these once the client supports the appropriate behavior for readRows

Change-Id: I4b5b0861e93f0a8b97d51556c74bccfe0b1da521

* Copy SqlRowMerger from internal code

This moves things mostly as is. I will move everything to appropriate packages in a follow on (e.g. utils will move to internal). Wanted to keep the changes as minimal as possible

Renames ProtoRowsBatchMergingStateMachine to ProtoRowsMergingStateMachine and removes the obsolete ProtoRowsMergingStateMachine

This simplifies the internal code by removing support for the old api. It should not change any behavior for he ProtoRowsBatch API

Change-Id: I8e8267a9cfeb59e0f8455876d1bccdb7c3778b76

* Implement main interfaces for interacting with ResultSets

This adds the main interfaces for interacting with data:
ResultSet, StructReader, and Struct. StructReader is used
by ResultSet, SqlRow, and Struct to provide a standard set
of accessors for the data.

I'm a little uncertain about the package structure right
now. I've put interfaces that users will interact with
directly in 'models' and everything else in 'internal'.
Internal will include both internal interfaces and the
implementations of the public interfaces. Otherwise I have
kept the package structure pretty flat but happy to group
the sql stuff together more.

This includes thorough documentation for the public interfaces.

Change-Id: I4535daffc596e9355da64b5655c58a68e5e7a95f

* Implement proto to java conversion via AbstractProtoStructReader

This will be re-used for structs in the following commit. The current
design implements this at the Row/Struct level instead of ResultSet &
Struct so that result set can operate on rows of different types when we
support arrow. ResultSet will then be a light wrapper where each getType
call is passed through to the current row.

Change-Id: I21fb4cc0cd830110d5455581491c5b1861efbcb1

* Add implementation for ProtoStruct

Change-Id: Ie9d3892fe92c779a6b81d457c31b534bdce20f38

* Implement ResultSet

This also removes the metadata helpers from the ResultSet interface.
These helpers will live on ResultSetMetadata instead.

Change-Id: Iba60b42b4e62f2d72c5a21206edf716c0ad5ea73

* Implement ResultSetMetadata and use it everwhere we operate on metadata

Also fix AbstractProtoStructReaderTest which was using the wrong runner
and not executing any tests. Fixes a couple test bugs as well.

Change-Id: Ia59459f93dd38046e9ac22995191becaad6ea44e

* Create execute query callables and wire up api to data client

This uses the ExecuteQueryCallContext to pass the metadata back
to the user using a future. Note that we need to be very careful
here that errors always close this future. That is why watchdog
happens higher in the call chain that for other streaming RPCs

Also note i decided to unwrap executeExceptions so that when
possible the future throws the same exceptions as the row stream

Change-Id: Ie9dd523a980efecb2cff010a2ffd7ac52b5f8ac7

* Add statement API for ExecuteQuery requests

Change-Id: Id9113adb24419da18f6e43e47c0c73cddf4b622e

* Implement java representation of Type protobuf

The admin types in admin.v2.models.Type will be migrated to
1) share the same implementation in common, while defining a
narrow interface like SqlType 2) be renamed to SchemaType.
We aren't going to block the Sql launch on this though. It
can happen after.

Change-Id: I9dea84fe9b7b2e0b46e8ece4cb666651183dc639

* Remove unsupported query param types and add doc

Change-Id: I41a28069865df6aa688ac5bc96181aae9f18deb4

* Add clirr exclusion for new proto method. Fix dropped import

Change-Id: I0cf3bd45a5f2bb3e2ad980d4170049d69e701d7e

* Small doc update and remove obsolete TODOs

Change-Id: Ie08217d025df3ec3c97dc96268f1c4e1d20b33bf

* Minor documentation fix for executeQuery

Change-Id: I6073e41b5a5b74b91671002cb93dc42c4023f10f

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
lqiu96 pushed a commit that referenced this pull request Jul 26, 2024
🤖 I have created a release *beep* *boop*
---


## [2.41.0](https://github.com/googleapis/java-bigtable/compare/v2.40.0...v2.41.0) (2024-07-24)


### Features

* Add MergeToCell to Mutation APIs ([#2279](https://github.com/googleapis/java-bigtable/issues/2279)) ([0ce8a2a](https://github.com/googleapis/java-bigtable/commit/0ce8a2a38703233da58208655f41f6e81e03576e))
* Add support for MergeToCell API ([#2258](https://github.com/googleapis/java-bigtable/issues/2258)) ([191d15c](https://github.com/googleapis/java-bigtable/commit/191d15c5284dbb702e11669931272877bf05f44e))
* Add support for new functions ([#2287](https://github.com/googleapis/java-bigtable/issues/2287)) ([dd6583a](https://github.com/googleapis/java-bigtable/commit/dd6583a22504385b7a1f7dc91b3bc3d2500ea0c5))
* Create new environment variable to toggle directpath scoped to cloud bigtable. ([#2261](https://github.com/googleapis/java-bigtable/issues/2261)) ([9062944](https://github.com/googleapis/java-bigtable/commit/9062944610277eb7ae77f395dc79ce94239c5bee))
* Implement ExecuteQuery API for SQL support ([#2280](https://github.com/googleapis/java-bigtable/issues/2280)) ([25218e8](https://github.com/googleapis/java-bigtable/commit/25218e8cc46f9a51d4b6515afdb8931e574b0bb1))


### Dependencies

* Update dependency com.google.truth.extensions:truth-proto-extension to v1.4.4 ([#2282](https://github.com/googleapis/java-bigtable/issues/2282)) ([d00a9e0](https://github.com/googleapis/java-bigtable/commit/d00a9e01b2b329f3bae50f48a15692d87ad0f3bf))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/java-bigtable API. size: xl Pull request size is extra large.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants