Skip to content

Commit

Permalink
Update ClickHouseHelperClient.java (#238)
Browse files Browse the repository at this point in the history
* Update ClickHouseHelperClient.java
  • Loading branch information
Paultagoras authored Nov 9, 2023
1 parent 8a2ef2a commit b247a49
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.4 2023-11-08
* Bugfix

## 1.0.3 2023-11-07
* Added support for proxy configurations
* Additional test cases
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.0.3
v1.0.4
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,11 @@ public ClickHouseResponse query(String query, ClickHouseFormat clickHouseFormat)
int retryCount = 0;
ClickHouseException ce = null;
while (retryCount < retry) {
try (ClickHouseClient client = ClickHouseClient.newInstance(ClickHouseProtocol.HTTP);
try (ClickHouseClient client = ClickHouseClient.builder()
.options(getDefaultClientOptions())
.nodeSelector(ClickHouseNodeSelector.of(ClickHouseProtocol.HTTP))
.build();
ClickHouseResponse response = client.read(server)
.options(getDefaultClientOptions())
.format(clickHouseFormat)
.query(query)
.executeAndWait()) {
Expand All @@ -138,9 +140,11 @@ public ClickHouseResponse query(String query, ClickHouseFormat clickHouseFormat)

public List<String> showTables() {
List<String> tablesNames = new ArrayList<>();
try (ClickHouseClient client = ClickHouseClient.newInstance(ClickHouseProtocol.HTTP);
try (ClickHouseClient client = ClickHouseClient.builder()
.options(getDefaultClientOptions())
.nodeSelector(ClickHouseNodeSelector.of(ClickHouseProtocol.HTTP))
.build();
ClickHouseResponse response = client.read(server)
.options(getDefaultClientOptions())
.query("SHOW TABLES")
.executeAndWait()) {
for (ClickHouseRecord r : response.records()) {
Expand All @@ -161,9 +165,11 @@ public Table describeTable(String tableName) {
String describeQuery = String.format("DESCRIBE TABLE `%s`.`%s`", this.database, tableName);
LOGGER.debug(describeQuery);

try (ClickHouseClient client = ClickHouseClient.newInstance(ClickHouseProtocol.HTTP);
try (ClickHouseClient client = ClickHouseClient.builder()
.options(getDefaultClientOptions())
.nodeSelector(ClickHouseNodeSelector.of(ClickHouseProtocol.HTTP))
.build();
ClickHouseResponse response = client.read(server)
.options(getDefaultClientOptions())
.query(describeQuery)
.executeAndWait()) {
Table table = new Table(tableName);
Expand Down

0 comments on commit b247a49

Please sign in to comment.