Skip to content

Conversation

wendigo
Copy link
Contributor

@wendigo wendigo commented Oct 8, 2025

Description

Additional context and related issues

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## CLI/JDBC/Client
* Negotiate zstd, brotli and gzip compression ({issue}`issuenumber`)

Summary by Sourcery

Enable optional Brotli, Zstd, and Gzip compression in the Trino client by adding the necessary dependencies, configuring a CompressionInterceptor in the HTTP client factory, and adjusting package relocation rules in the JDBC client

New Features:

  • Add support for Brotli, Zstd, and Gzip compression in the HTTP client

Enhancements:

  • Add okhttp-brotli and okhttp-zstd dependencies and configure a CompressionInterceptor in HttpClientFactory
  • Relocate com.squareup and org.brotli packages in the JDBC client to prevent classpath conflicts

Tests:

  • Update JdbcDriverIT to recognize jni/ directory entries in the shaded file manifest

@cla-bot cla-bot bot added the cla-signed label Oct 8, 2025
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 8, 2025

Reviewer's Guide

This PR implements client-side support for Zstd, Brotli, and Gzip compression by adding the necessary dependencies, wiring a CompressionInterceptor into the OkHttpClient builder based on URI settings, updating the JDBC shading plugin to relocate the new libraries, and adjusting the JDBC driver tests to recognize jni artifacts.

Class diagram for CompressionInterceptor integration

classDiagram
    class HttpClientFactory {
        +unauthenticatedClientBuilder(uri: TrinoUri, String): OkHttpClient.Builder
        -setupCompression(builder: OkHttpClient.Builder)
    }
    class CompressionInterceptor {
        +CompressionInterceptor(zstd: Zstd, brotli: Brotli, gzip: Gzip)
    }
    class Zstd
    class Brotli
    class Gzip
    HttpClientFactory --> CompressionInterceptor : uses
    CompressionInterceptor --> Zstd : uses
    CompressionInterceptor --> Brotli : uses
    CompressionInterceptor --> Gzip : uses
Loading

File-Level Changes

Change Details Files
Add compression libraries to the Trino client
  • Add okhttp-brotli dependency
  • Add okhttp-zstd dependency
client/trino-client/pom.xml
Introduce and invoke HTTP compression interceptor
  • Call setupCompression when compression is enabled
  • Implement setupCompression with Zstd, Brotli, Gzip
client/trino-client/src/main/java/io/trino/client/uri/HttpClientFactory.java
Shade new compression libraries in JDBC client
  • Relocate com.squareup packages under shadeBase.squareup
  • Relocate org.brotli packages under shadeBase.brotli
client/trino-jdbc/pom.xml
Allow JNI entries in JDBC driver manifest test
  • Include files starting with "jni/" in expected manifest set
client/trino-jdbc/src/test/java/io/trino/jdbc/JdbcDriverIT.java

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the jdbc Relates to Trino JDBC driver label Oct 8, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@wendigo
Copy link
Contributor Author

wendigo commented Oct 8, 2025

I've checked that compression is negotiated by the client when it's enabled on the server side:

--> GET http://localhost:8080/v1/statement/executing/20251008_115929_00001_3khev/y8f21646c0fcee9a74855f74dbd0f2e49a3223701/2 http/1.1
X-Trino-User: mateusz.gajewski
X-Trino-Original-User: mateusz.gajewski
User-Agent: trino-cli/477-test-1-333-gefcf10c-dirty os=Mac_OS_X os/version=26.0.1 arch=aarch64 lang/java=25+36-LTS java/vm=OpenJDK_64-Bit_Server_VM java/vendor=Eclipse_Adoptium locale=pl-PL
Accept-Encoding: zstd, br, gzip
Host: localhost:8080
Connection: Keep-Alive
--> END GET
<-- 200 OK http://localhost:8080/v1/statement/executing/20251008_115929_00001_3khev/y8f21646c0fcee9a74855f74dbd0f2e49a3223701/2 (3ms)
Date: Wed, 08 Oct 2025 11:59:29 GMT
Vary: Accept-Encoding
Content-Type: application/json
X-Content-Type-Options: nosniff
Content-Encoding: zstd
Transfer-Encoding: chunked

@wendigo wendigo requested review from ebyhr and raunaqmorarka October 8, 2025 12:00
@wendigo wendigo merged commit 6b8872e into master Oct 8, 2025
309 of 312 checks passed
@wendigo wendigo deleted the serafin/okhttp-compression branch October 8, 2025 13:27
@github-actions github-actions bot added this to the 478 milestone Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed jdbc Relates to Trino JDBC driver

Development

Successfully merging this pull request may close these issues.

2 participants