Skip to content

ClickHouseIO - Improve user agent#37815

Merged
Abacn merged 9 commits intoapache:masterfrom
BentsiLeviav:improve-user-agent
Apr 17, 2026
Merged

ClickHouseIO - Improve user agent#37815
Abacn merged 9 commits intoapache:masterfrom
BentsiLeviav:improve-user-agent

Conversation

@BentsiLeviav
Copy link
Copy Markdown
Contributor

Description

  • Updated the user agent setting name from product_name (deprecated) to client_name
  • Create a shared logic for building the user agent
  • Make sure we concat any external client_name to the base user agent
  • Rename the original test class to IT
  • Create a new test class for unit tests
  • Add unit tests for the new user agent logic

Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the user agent handling within the ClickHouseIO connector to align with modern practices and improve testability. It deprecates an older user agent property in favor of a more current one and introduces a centralized mechanism for constructing the user agent string, allowing for better extensibility and consistency. Furthermore, the testing suite has been reorganized to clearly separate unit tests from integration tests, enhancing the clarity and maintainability of the test codebase.

Highlights

  • User Agent Update: Updated the user agent property from "product_name" to "client_name" in ClickHouseIO.java, aligning with modern practices.
  • Shared User Agent Logic: Implemented a shared "buildClientName" method to standardize user agent string construction, ensuring proper concatenation with existing client names.
  • Test Class Refactoring: Refactored the existing "ClickHouseIOTest" class into "ClickHouseIOIT" to specifically house integration tests.
  • New Unit Test Class: Created a new "ClickHouseIOTest" class dedicated to unit tests, particularly for the new user agent logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • sdks/java/io/clickhouse/src/main/java/org/apache/beam/sdk/io/clickhouse/ClickHouseIO.java
    • Replaced the deprecated "product_name" property with "client_name" when setting the user agent.
    • Introduced a new static method "buildClientName" to encapsulate the logic for creating the user agent string, including appending any pre-existing client names.
    • Updated all relevant "setClientName" calls to utilize the new "buildClientName" method.
  • sdks/java/io/clickhouse/src/test/java/org/apache/beam/sdk/io/clickhouse/ClickHouseIOIT.java
    • Added a new file, which is an integration test class for ClickHouseIO.
    • Included comprehensive tests for various data types (Int64, Nullable Int64, Array of Array of Int64, Primitive Types, Array of Primitive Types) and complex schema types (TupleType, Complex TupleType), ensuring robust interaction with a ClickHouse instance.
  • sdks/java/io/clickhouse/src/test/java/org/apache/beam/sdk/io/clickhouse/ClickHouseIOTest.java
    • Modified the existing test file to remove all integration tests, moving them to ClickHouseIOIT.java.
    • Added new unit tests for the "buildClientName" method, covering scenarios with no existing client name, an empty client name, and an existing client name.
Activity
  • No human activity (comments, reviews, etc.) was found in the provided context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @Abacn for label java.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

set(properties, "insert_distributed_sync", insertDistributedSync());
set(properties, "insert_deduplication", insertDeduplicate());
set(properties, "product_name", userAgent);
set(properties, "client_name", buildClientName(properties));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add it to documentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a section about it to the auto generated docs

* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.beam.sdk.io.clickhouse;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have started to make Product Name integration tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added a test named testUserAgentInQueryLog to ClickHouseIOIT

@BentsiLeviav BentsiLeviav requested a review from mzitnik March 22, 2026 10:35
Copy link
Copy Markdown
Contributor

@mzitnik mzitnik left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread sdks/java/io/clickhouse/build.gradle Outdated

test {
// Include integration tests (Testcontainers-based *IT classes) alongside unit tests
include "**/*IT.class"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

test is for unit tests. Integration test should locates in integrationTest task. To do so, add

provideIntegrationTestingDependencies()
enableJavaPerformanceTesting()

(see https://github.com/apache/beam/blob/master/sdks/java/io/jdbc/build.gradle for example)
then add the target to

gradle-command: :sdks:java:io:clickhouse:build

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@Abacn Tnx! moved it

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

Reminder, please take a look at this pr: @Abacn

@github-actions github-actions Bot added the build label Apr 5, 2026
@BentsiLeviav BentsiLeviav requested a review from Abacn April 5, 2026 09:03
@github-actions github-actions Bot removed the build label Apr 5, 2026

/** Tests for {@link ClickHouseIO}. */
@RunWith(JUnit4.class)
public class ClickHouseIOIT extends BaseClickHouseTest {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I realize previously unit test runs both unit test and integration test. We can now move the integration test (running against real test container) into IT. This involves the following,

BaseClickHouseTest is a test fixture and does not contain an actual test. Consider name it "ClickHouseTestBase"

rename AtomicInsertTest to AtomicInsertIT

@github-actions
Copy link
Copy Markdown
Contributor

Assigning new set of reviewers because Pr has gone too long without review. If you would like to opt out of this review, comment assign to next reviewer:

R: @ahmedabu98 for label java.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

@github-actions
Copy link
Copy Markdown
Contributor

Reminder, please take a look at this pr: @ahmedabu98

Copy link
Copy Markdown
Contributor

@Abacn Abacn left a comment

Choose a reason for hiding this comment

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

Thank you!

@Abacn Abacn merged commit f300e59 into apache:master Apr 17, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants