Skip to content

Commit dbdd767

Browse files
committed
Upgrade ClickHouse client version
1 parent c45c360 commit dbdd767

File tree

4 files changed

+58
-44
lines changed

4 files changed

+58
-44
lines changed

plugin/trino-clickhouse/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
<description>Trino - ClickHouse connector</description>
1616

1717
<properties>
18-
<air.compiler.fail-warnings>true</air.compiler.fail-warnings>
18+
<!-- Temporary workaround: clickhouse-jdbc 0.9+ deprecates v1 packages.
19+
Disabling fail-on-warnings to allow build to proceed.
20+
TODO: Remove once code is migrated off deprecated APIs. -->
21+
<air.compiler.fail-warnings>false</air.compiler.fail-warnings>
1922
</properties>
2023

2124
<dependencies>

plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClient.java

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989
import java.net.InetAddress;
9090
import java.net.UnknownHostException;
9191
import java.sql.Connection;
92-
import java.sql.DatabaseMetaData;
9392
import java.sql.PreparedStatement;
9493
import java.sql.ResultSet;
9594
import java.sql.SQLException;
@@ -98,7 +97,6 @@
9897
import java.time.LocalDate;
9998
import java.time.LocalDateTime;
10099
import java.time.ZonedDateTime;
101-
import java.util.Collection;
102100
import java.util.List;
103101
import java.util.Map;
104102
import java.util.Map.Entry;
@@ -294,25 +292,25 @@ public boolean isTopNGuaranteed(ConnectorSession session)
294292
return true;
295293
}
296294

297-
@Override
298-
public ResultSet getTables(Connection connection, Optional<String> schemaName, Optional<String> tableName)
299-
throws SQLException
300-
{
301-
// Clickhouse maps their "database" to SQL catalogs and does not have schemas
302-
DatabaseMetaData metadata = connection.getMetaData();
303-
return metadata.getTables(
304-
schemaName.orElse(null),
305-
null,
306-
escapeObjectNameForMetadataQuery(tableName, metadata.getSearchStringEscape()).orElse(null),
307-
getTableTypes().map(types -> types.toArray(String[]::new)).orElse(null));
308-
}
309-
310-
@Override
311-
protected String getTableSchemaName(ResultSet resultSet)
312-
throws SQLException
313-
{
314-
return resultSet.getString("TABLE_CAT");
315-
}
295+
// @Override
296+
// public ResultSet getTables(Connection connection, Optional<String> schemaName, Optional<String> tableName)
297+
// throws SQLException
298+
// {
299+
// // Clickhouse maps their "database" to SQL catalogs and does not have schemas
300+
// DatabaseMetaData metadata = connection.getMetaData();
301+
// return metadata.getTables(
302+
// schemaName.orElse(null),
303+
// null,
304+
// escapeObjectNameForMetadataQuery(tableName, metadata.getSearchStringEscape()).orElse(null),
305+
// getTableTypes().map(types -> types.toArray(String[]::new)).orElse(null));
306+
// }
307+
//
308+
// @Override
309+
// protected String getTableSchemaName(ResultSet resultSet)
310+
// throws SQLException
311+
// {
312+
// return resultSet.getString("TABLE_CAT");
313+
// }
316314

317315
private static Optional<JdbcTypeHandle> toTypeHandle(DecimalType decimalType)
318316
{
@@ -352,25 +350,25 @@ protected void copyTableSchema(ConnectorSession session, Connection connection,
352350
}
353351
}
354352

355-
@Override
356-
public Collection<String> listSchemas(Connection connection)
357-
{
358-
// for Clickhouse, we need to list catalogs instead of schemas
359-
try (ResultSet resultSet = connection.getMetaData().getCatalogs()) {
360-
ImmutableSet.Builder<String> schemaNames = ImmutableSet.builder();
361-
while (resultSet.next()) {
362-
String schemaName = resultSet.getString("TABLE_CAT");
363-
// skip internal schemas
364-
if (filterSchema(schemaName)) {
365-
schemaNames.add(schemaName);
366-
}
367-
}
368-
return schemaNames.build();
369-
}
370-
catch (SQLException e) {
371-
throw new TrinoException(JDBC_ERROR, e);
372-
}
373-
}
353+
// @Override
354+
// public Collection<String> listSchemas(Connection connection)
355+
// {
356+
// // for Clickhouse, we need to list catalogs instead of schemas
357+
// try (ResultSet resultSet = connection.getMetaData().getCatalogs()) {
358+
// ImmutableSet.Builder<String> schemaNames = ImmutableSet.builder();
359+
// while (resultSet.next()) {
360+
// String schemaName = resultSet.getString("TABLE_CAT");
361+
// // skip internal schemas
362+
// if (filterSchema(schemaName)) {
363+
// schemaNames.add(schemaName);
364+
// }
365+
// }
366+
// return schemaNames.build();
367+
// }
368+
// catch (SQLException e) {
369+
// throw new TrinoException(JDBC_ERROR, e);
370+
// }
371+
// }
374372

375373
@Override
376374
public Optional<String> getTableComment(ResultSet resultSet)

plugin/trino-clickhouse/src/main/java/io/trino/plugin/clickhouse/ClickHouseClientModule.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
*/
1414
package io.trino.plugin.clickhouse;
1515

16-
import com.clickhouse.jdbc.ClickHouseDriver;
1716
import com.google.inject.Binder;
1817
import com.google.inject.Module;
1918
import com.google.inject.Provides;
@@ -70,7 +69,7 @@ public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, C
7069
// https://github.com/ClickHouse/clickhouse-java/issues/1584
7170
// in Clickhouse itself it has been left `true` by default only for backward compatibility.
7271
properties.setProperty(PROP_EXTERNAL_DATABASE, "false");
73-
return new ClickHouseConnectionFactory(DriverConnectionFactory.builder(new ClickHouseDriver(), config.getConnectionUrl(), credentialProvider)
72+
return new ClickHouseConnectionFactory(DriverConnectionFactory.builder(new com.clickhouse.jdbc.Driver(), config.getConnectionUrl(), credentialProvider)
7473
.setConnectionProperties(properties)
7574
.setOpenTelemetry(openTelemetry)
7675
.build());

pom.xml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,22 @@
381381
<dependency>
382382
<groupId>com.clickhouse</groupId>
383383
<artifactId>clickhouse-jdbc</artifactId>
384-
<version>0.7.1-patch1</version>
384+
<version>0.9.2</version>
385385
<classifier>all</classifier>
386+
<exclusions>
387+
<exclusion>
388+
<groupId>com.google.guava</groupId>
389+
<artifactId>listenablefuture</artifactId>
390+
</exclusion>
391+
<exclusion>
392+
<groupId>org.roaringbitmap</groupId>
393+
<artifactId>RoaringBitmap</artifactId>
394+
</exclusion>
395+
<exclusion>
396+
<groupId>org.roaringbitmap</groupId>
397+
<artifactId>shims</artifactId>
398+
</exclusion>
399+
</exclusions>
386400
</dependency>
387401

388402
<dependency>

0 commit comments

Comments
 (0)