Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion plugin/trino-clickhouse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
<description>Trino - ClickHouse connector</description>

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

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
Expand All @@ -98,7 +97,6 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -294,25 +292,25 @@ public boolean isTopNGuaranteed(ConnectorSession session)
return true;
}

@Override
public ResultSet getTables(Connection connection, Optional<String> schemaName, Optional<String> tableName)
throws SQLException
{
// Clickhouse maps their "database" to SQL catalogs and does not have schemas
DatabaseMetaData metadata = connection.getMetaData();
return metadata.getTables(
schemaName.orElse(null),
null,
escapeObjectNameForMetadataQuery(tableName, metadata.getSearchStringEscape()).orElse(null),
getTableTypes().map(types -> types.toArray(String[]::new)).orElse(null));
}

@Override
protected String getTableSchemaName(ResultSet resultSet)
throws SQLException
{
return resultSet.getString("TABLE_CAT");
}
// @Override
// public ResultSet getTables(Connection connection, Optional<String> schemaName, Optional<String> tableName)
// throws SQLException
// {
// // Clickhouse maps their "database" to SQL catalogs and does not have schemas
// DatabaseMetaData metadata = connection.getMetaData();
// return metadata.getTables(
// schemaName.orElse(null),
// null,
// escapeObjectNameForMetadataQuery(tableName, metadata.getSearchStringEscape()).orElse(null),
// getTableTypes().map(types -> types.toArray(String[]::new)).orElse(null));
// }
//
// @Override
// protected String getTableSchemaName(ResultSet resultSet)
// throws SQLException
// {
// return resultSet.getString("TABLE_CAT");
// }

private static Optional<JdbcTypeHandle> toTypeHandle(DecimalType decimalType)
{
Expand Down Expand Up @@ -352,25 +350,25 @@ protected void copyTableSchema(ConnectorSession session, Connection connection,
}
}

@Override
public Collection<String> listSchemas(Connection connection)
{
// for Clickhouse, we need to list catalogs instead of schemas
try (ResultSet resultSet = connection.getMetaData().getCatalogs()) {
ImmutableSet.Builder<String> schemaNames = ImmutableSet.builder();
while (resultSet.next()) {
String schemaName = resultSet.getString("TABLE_CAT");
// skip internal schemas
if (filterSchema(schemaName)) {
schemaNames.add(schemaName);
}
}
return schemaNames.build();
}
catch (SQLException e) {
throw new TrinoException(JDBC_ERROR, e);
}
}
// @Override
// public Collection<String> listSchemas(Connection connection)
// {
// // for Clickhouse, we need to list catalogs instead of schemas
// try (ResultSet resultSet = connection.getMetaData().getCatalogs()) {
// ImmutableSet.Builder<String> schemaNames = ImmutableSet.builder();
// while (resultSet.next()) {
// String schemaName = resultSet.getString("TABLE_CAT");
// // skip internal schemas
// if (filterSchema(schemaName)) {
// schemaNames.add(schemaName);
// }
// }
// return schemaNames.build();
// }
// catch (SQLException e) {
// throw new TrinoException(JDBC_ERROR, e);
// }
// }

@Override
public Optional<String> getTableComment(ResultSet resultSet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package io.trino.plugin.clickhouse;

import com.clickhouse.jdbc.ClickHouseDriver;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
Expand Down Expand Up @@ -70,7 +69,7 @@ public static ConnectionFactory createConnectionFactory(BaseJdbcConfig config, C
// https://github.com/ClickHouse/clickhouse-java/issues/1584
// in Clickhouse itself it has been left `true` by default only for backward compatibility.
properties.setProperty(PROP_EXTERNAL_DATABASE, "false");
return new ClickHouseConnectionFactory(DriverConnectionFactory.builder(new ClickHouseDriver(), config.getConnectionUrl(), credentialProvider)
return new ClickHouseConnectionFactory(DriverConnectionFactory.builder(new com.clickhouse.jdbc.Driver(), config.getConnectionUrl(), credentialProvider)
.setConnectionProperties(properties)
.setOpenTelemetry(openTelemetry)
.build());
Expand Down
16 changes: 15 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,22 @@
<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.7.1-patch1</version>
<version>0.9.2</version>
<classifier>all</classifier>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>listenablefuture</artifactId>
</exclusion>
<exclusion>
<groupId>org.roaringbitmap</groupId>
<artifactId>RoaringBitmap</artifactId>
</exclusion>
<exclusion>
<groupId>org.roaringbitmap</groupId>
<artifactId>shims</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Loading