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

Add Looker SDK and streaming support #2

Merged
merged 14 commits into from
Sep 20, 2023
Merged

Conversation

tjbanghart
Copy link
Member

@tjbanghart tjbanghart commented Jul 27, 2023

Adds functionality described in go/scaling-avatica-looker-api.

To enable the the Looker SDK use jdbc:looker (as opposed to jdbc:avatica:remote) as the JDBC URL protocol.
NOTE: This is awaiting changes from b/288031194. Don't expect this to work properly without that work completed.

TODOs:

  • Unit tests for everything but definitely the streaming parser.
  • Use sql_interface endpoints.
  • Ensure OAuth tokens are set as AuthTokens rather than raw header.
  • Handle metadata from json_bi result format. We currently skip right to rows.
  • Support prepared statements. i.e. those that Prepare then later Execute. Currently we only override PrepareAndExecute
  • Kotlin: support streaming sdk-codegen#1341 - not going to happen for awhile. Requires large refactor to the SDK gen.

@tjbanghart tjbanghart requested review from mkou, wnob and olivrlee July 27, 2023 21:26
Copy link

@wnob wnob left a comment

Choose a reason for hiding this comment

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

Leaving some general readability comments for now. Will think harder about this later. Since this is going to be a permanent "fixup" commit, we should be pretty careful about making sure it remains easy to rebase on master for every bump, so good to think about exactly how to break it into smaller commits for easy maintenance in posterity.

build.gradle.kts Outdated
@@ -176,6 +176,8 @@ allprojects {
plugins.withId("java-library") {
dependencies {
"implementation"(platform(project(":bom")))
// Add the locally bundled LookerSDK fat jar
"implementation"(files("../libs/looker-kotlin-sdk-f91f8ad.jar"))
Copy link

Choose a reason for hiding this comment

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

Feels like we should file a cleanup bug to make this integration easier and throw it in the backlog for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah definitely - we will be building this jars locally for the foreseeable future. There was talk of getting this on maven and tied to official releases but I don't think that will happen soon.


@Test
public void driverThrowsAuthExceptionForBlankProperties() throws SQLException {
Properties props = new Properties();
Copy link

Choose a reason for hiding this comment

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

http://go/unit-test-practices#structure

I find the arrange - act - assert structure does a lot for test readability. Just put some blank space in between each section. It's OK if some tests are more like arrange - act - assert - act - assert.

@tjbanghart
Copy link
Member Author

Thanks for the review @wnob!

I am still exploring what we would need to have upstream, but my hope is that we can keep all meaningful changes in org.apache.calcite.avatica.remote.looker. I would like this to be an extension of the remote Avatica driver rather than a fixup to existing implementations. There might be some changes here that others would benefit from, but I don't believe much of this should make it into main with the exception of some class + method visibility changes (which do need Jira cases).

That said, response streaming into a series of Frames may be something to lift out of this and would probably benefit most from open-source contributions. Perhaps it makes sense to open a Jira case for this as well... on the other hand the streamed response is specific to Looker's json_bi format.

IMO, Avatica has been open enough that we have not had to modify existing classes extensively. Any areas where this PR has done such modifications highlight potential Jira cases for upstream.

@tjbanghart tjbanghart force-pushed the tjbanghart/looker-sdk branch from 78906b2 to aa93bd9 Compare September 8, 2023 16:55
@tjbanghart tjbanghart requested review from barrkel and wnob September 8, 2023 16:57
@tjbanghart tjbanghart force-pushed the tjbanghart/looker-sdk branch from b53d4d6 to d9826eb Compare September 20, 2023 05:13
@tjbanghart tjbanghart changed the title WIP: Add Looker SDK and streaming support Add Looker SDK and streaming support Sep 20, 2023
@tjbanghart tjbanghart merged commit dbe2821 into looker Sep 20, 2023
1 check passed
wnob pushed a commit that referenced this pull request Feb 13, 2024
* Initial Looker SDK branch commit

* Streaming LookerIterator

* True streaming support

* Make a specific Driver class and 'jdbc:looker:' protocol support

* Add read timeout for stream

* SQL Interface API endpoints

* Use BlockingQueue of FrameEnvelopes rather than IO pipes

* Fix illegal cast for queries with a single column

* Stub driver for LookerRemoteMetaTest

* Address feedback

* Handle null values in stream

* Rename driver to LookerDriver

* Better error handling from API response

* Support userAgent and make LookerResponseParser public for testing
jswett77 pushed a commit that referenced this pull request Feb 14, 2024
* Initial Looker SDK branch commit

* Streaming LookerIterator

* True streaming support

* Make a specific Driver class and 'jdbc:looker:' protocol support

* Add read timeout for stream

* SQL Interface API endpoints

* Use BlockingQueue of FrameEnvelopes rather than IO pipes

* Fix illegal cast for queries with a single column

* Stub driver for LookerRemoteMetaTest

* Address feedback

* Handle null values in stream

* Rename driver to LookerDriver

* Better error handling from API response

* Support userAgent and make LookerResponseParser public for testing
wnob pushed a commit that referenced this pull request Feb 15, 2024
* Initial Looker SDK branch commit

* Streaming LookerIterator

* True streaming support

* Make a specific Driver class and 'jdbc:looker:' protocol support

* Add read timeout for stream

* SQL Interface API endpoints

* Use BlockingQueue of FrameEnvelopes rather than IO pipes

* Fix illegal cast for queries with a single column

* Stub driver for LookerRemoteMetaTest

* Address feedback

* Handle null values in stream

* Rename driver to LookerDriver

* Better error handling from API response

* Support userAgent and make LookerResponseParser public for testing
tjbanghart added a commit that referenced this pull request Jun 21, 2024
* Initial Looker SDK branch commit

* Streaming LookerIterator

* True streaming support

* Make a specific Driver class and 'jdbc:looker:' protocol support

* Add read timeout for stream

* SQL Interface API endpoints

* Use BlockingQueue of FrameEnvelopes rather than IO pipes

* Fix illegal cast for queries with a single column

* Stub driver for LookerRemoteMetaTest

* Address feedback

* Handle null values in stream

* Rename driver to LookerDriver

* Better error handling from API response

* Support userAgent and make LookerResponseParser public for testing
tjbanghart added a commit that referenced this pull request Jun 21, 2024
* Initial Looker SDK branch commit

* Streaming LookerIterator

* True streaming support

* Make a specific Driver class and 'jdbc:looker:' protocol support

* Add read timeout for stream

* SQL Interface API endpoints

* Use BlockingQueue of FrameEnvelopes rather than IO pipes

* Fix illegal cast for queries with a single column

* Stub driver for LookerRemoteMetaTest

* Address feedback

* Handle null values in stream

* Rename driver to LookerDriver

* Better error handling from API response

* Support userAgent and make LookerResponseParser public for testing
tjbanghart added a commit that referenced this pull request Jun 26, 2024
* Initial Looker SDK branch commit

* Streaming LookerIterator

* True streaming support

* Make a specific Driver class and 'jdbc:looker:' protocol support

* Add read timeout for stream

* SQL Interface API endpoints

* Use BlockingQueue of FrameEnvelopes rather than IO pipes

* Fix illegal cast for queries with a single column

* Stub driver for LookerRemoteMetaTest

* Address feedback

* Handle null values in stream

* Rename driver to LookerDriver

* Better error handling from API response

* Support userAgent and make LookerResponseParser public for testing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants