Skip to content

Cluster mode for clickhouse connector #25447

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vixns
Copy link

@vixns vixns commented Mar 28, 2025

PR based on #17433 by @nelsonspark

Fixes #17307

Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@github-actions github-actions bot added docs clickhouse ClickHouse connector labels Mar 28, 2025
@vixns vixns force-pushed the clickhouse_cluster branch from 4a2c9ce to 1066dd6 Compare March 28, 2025 11:26
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@vixns vixns force-pushed the clickhouse_cluster branch from 1066dd6 to 1518fa7 Compare March 28, 2025 11:43
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@vixns vixns force-pushed the clickhouse_cluster branch from 1518fa7 to 5f9ccf3 Compare March 28, 2025 11:46
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@vixns vixns force-pushed the clickhouse_cluster branch from 5f9ccf3 to 09902ea Compare March 28, 2025 12:01
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@vixns vixns force-pushed the clickhouse_cluster branch from 09902ea to 9eabbce Compare March 28, 2025 12:04
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@vixns vixns force-pushed the clickhouse_cluster branch from 9eabbce to 226d472 Compare March 28, 2025 13:33
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@vixns vixns force-pushed the clickhouse_cluster branch from 226d472 to 93567b9 Compare March 28, 2025 14:03
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@vixns vixns force-pushed the clickhouse_cluster branch from 93567b9 to 864dc3b Compare March 28, 2025 17:06
Copy link

cla-bot bot commented Mar 28, 2025

Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to [email protected]. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla

@@ -253,6 +256,11 @@ public ClickHouseClient(
.build());
}

private String getClusterInfo()
Copy link
Member

Choose a reason for hiding this comment

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

Adding ON CLUSTER to all queries is error-prone. ClickHouse doesn't support configuring the cluster at connection level with JDBC property or something?

Copy link
Author

Choose a reason for hiding this comment

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

https://clickhouse.com/docs/sql-reference/distributed-ddl

But yes, it's not that simple, as you can read on https://clickhouse.com/docs/engines/table-engines/special/distributed

In short, you have to create/alter tables on each node using the ON CLUSTER ... , and then create a "virtual" distributed table using the "real" tables as data source.

It may be required to add this distributed table when creating the real ones, I'm not (yet) used to clickhouse cluster mode.

@@ -35,4 +38,20 @@ public ClickHouseConfig setMapStringAsVarchar(boolean mapStringAsVarchar)
this.mapStringAsVarchar = mapStringAsVarchar;
return this;
}

private Optional<String> clusterName = Optional.empty();
Copy link
Member

Choose a reason for hiding this comment

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

Move under mapStringAsVarchar.

return clusterName;
}

@Config("clickhouse.cluster-name")
Copy link
Member

Choose a reason for hiding this comment

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

We should test all statements with this property. TestClickHouseConfig is insufficient.

@ebyhr
Copy link
Member

ebyhr commented Mar 31, 2025

Did you submit CLA?

@vixns
Copy link
Author

vixns commented Mar 31, 2025

Did you submit CLA?

yes

Copy link

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions bot added the stale label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clickhouse ClickHouse connector docs stale
Development

Successfully merging this pull request may close these issues.

Support specifying cluster name in ClickHouse connector
2 participants