Skip to content

Commit

Permalink
[Fix-2248][admin][metadata] Modification only supports clickhouse dri…
Browse files Browse the repository at this point in the history
…ver version 0.2.6 (#3659)

Signed-off-by: Zzm0809 <[email protected]>
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
LiuHao0606 and Zzm0809 authored Jul 27, 2024
1 parent 4c8d037 commit 5990630
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public String getLimitClause(long limit) {

@Override
public Optional<String> defaultDriverName() {
return Optional.of("ru.yandex.clickhouse.ClickHouseDriver");
return Optional.of("com.clickhouse.jdbc.ClickHouseDriver");
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion dinky-extends/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
<properties>
<flink.version>1.13.3</flink.version>

<clickhouse-jdbc.version>0.2.6</clickhouse-jdbc.version>
<clickhouse-jdbc.version>0.6.2</clickhouse-jdbc.version>
<mariadb-java-client.version>2.5.4</mariadb-java-client.version>
<maven.compiler.target>${target.java.version}</maven.compiler.target>
<derby.version>10.14.2.0</derby.version>
Expand Down
2 changes: 1 addition & 1 deletion dinky-metadata/dinky-metadata-clickhouse/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class ClickHouseDriver extends AbstractJdbcDriver {

@Override
String getDriverClass() {
return "ru.yandex.clickhouse.ClickHouseDriver";
return "com.clickhouse.jdbc.ClickHouseDriver";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.dinky.metadata.driver.ClickHouseDriver;
import org.dinky.metadata.driver.Driver;
import org.dinky.metadata.result.JdbcSelectResult;
import org.dinky.utils.JsonUtils;

import java.util.List;

Expand All @@ -46,52 +47,65 @@ public class ClickHouseTest {

private static final Logger LOGGER = LoggerFactory.getLogger(ClickHouseTest.class);

private static final String IP = "127.0.0.1";
private static final String IP = "0.0.0.0";
private static final int PORT = 8123;
private static final String url = StrFormatter.format("jdbc:clickhouse://{}:{}/default", IP, PORT);
private static final String url = StrFormatter.format("jdbc:clickhouse://{}:{}/ads", IP, PORT);

private final ClickHouseDriver clickHouseDriver = new ClickHouseDriver();

public Driver getDriver() {
DriverConfig<AbstractJdbcConfig> config = new DriverConfig<>();
config.setType(clickHouseDriver.getType());
config.setName(clickHouseDriver.getName());
config.setConnectConfig(
AbstractJdbcConfig.builder().ip(IP).port(PORT).url(url).build());
config.setConnectConfig(AbstractJdbcConfig.builder()
.ip(IP)
.port(PORT)
.url(url)
.username("xx")
.password("xx")
.build());
return Driver.build(config);
}

@Ignore
@Test
public void connectTest() {
String test = getDriver().test();
// LOGGER.info(test);
LOGGER.info(test);
// LOGGER.info("end...");
}

@Ignore
@Test
public void schemaTest() {
List<Schema> schemasAndTables = getDriver().getSchemasAndTables();
// LOGGER.info(JsonUtils.toJsonString(schemasAndTables));
Driver driver = getDriver();
String test = driver.test();
Driver connect = driver.connect();

List<Schema> schemasAndTables = driver.getSchemasAndTables();
LOGGER.info(JsonUtils.toJsonString(schemasAndTables));
// LOGGER.info("end...");
}

@Ignore
@Test
public void columnTest() {
Driver driver = getDriver();
List<Column> columns = driver.listColumns("xxx", "xxx");
// LOGGER.info(JsonUtils.toJsonString(columns));
String test = driver.test();
Driver connect = driver.connect();
List<Column> columns = driver.listColumns("xx", "xx");
LOGGER.info(JsonUtils.toJsonString(columns));
// LOGGER.info("end...");
}

@Ignore
@Test
public void queryTest() {
Driver driver = getDriver();
JdbcSelectResult query = driver.query("select * from xxx", 10);
// LOGGER.info(JsonUtils.toJsonString(query));
String test = driver.test();
Driver connect = driver.connect();
JdbcSelectResult query = driver.query("select count(1) from xx.xx", 10);
LOGGER.info(query.getRowData().toString());
// LOGGER.info("end...");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FlinkDDL 等。
目前支持的数据源类型包括:MySQL、Oracle、PostgreSQL、SQLServer、Phoenix、ClickHouse、Doris、StartRocks、Presto、Hive。

注意: 1.删除前会进行引用检查,如果有作业引用该数据源,将无法删除。
2.在连接clickhosue数据源时,使用0.3.2以下版本,推荐:clickhouse-jdbc-0.2.6.jar
2.在连接clickhosue数据源时,推荐使用0.3.2及以上版本【官方推荐在连接clickhosue时候,使用com.clickhouse.jdbc.ClickHouseDriver,ru.yandex.clickhouse.ClickHouseDriver已废弃】
:::

## 数据源管理
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<assertj.version>3.21.0</assertj.version>
<aws-java-sdk-s3.version>1.12.645</aws-java-sdk-s3.version>
<build-helper-maven-plugin.version>1.7</build-helper-maven-plugin.version>
<clickhouse.version>0.2.6</clickhouse.version>
<clickhouse.version>0.6.2</clickhouse.version>
<commons-email>1.5</commons-email>
<!-- jexl cannot be upgraded to 3.3, and static methods need to be used.(jexl不能升级到3.3,需要使用到静态方法的使用) -->
<commons-jexl3>3.2.1</commons-jexl3>
Expand Down Expand Up @@ -377,7 +377,7 @@
<version>${ojdbc8.version}</version>
</dependency>
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>${clickhouse.version}</version>
</dependency>
Expand Down

0 comments on commit 5990630

Please sign in to comment.