|
2 | 2 |
|
3 | 3 | import org.apache.flink.connector.clickhouse.ClickHouseDynamicTableFactory;
|
4 | 4 | import org.apache.flink.connector.clickhouse.internal.schema.DistributedEngineFull;
|
5 |
| -import org.apache.flink.connector.clickhouse.util.ClickHouseUtil; |
6 | 5 | import org.apache.flink.connector.clickhouse.util.DataTypeUtil;
|
7 | 6 | import org.apache.flink.table.api.TableSchema;
|
8 | 7 | import org.apache.flink.table.catalog.AbstractCatalog;
|
|
33 | 32 | import org.apache.flink.table.factories.Factory;
|
34 | 33 | import org.apache.flink.table.types.DataType;
|
35 | 34 |
|
| 35 | +import com.clickhouse.client.config.ClickHouseDefaults; |
| 36 | +import com.clickhouse.data.ClickHouseColumn; |
| 37 | +import com.clickhouse.jdbc.ClickHouseConnection; |
| 38 | +import com.clickhouse.jdbc.ClickHouseDriver; |
| 39 | +import com.clickhouse.jdbc.ClickHouseResultSetMetaData; |
36 | 40 | import org.slf4j.Logger;
|
37 | 41 | import org.slf4j.LoggerFactory;
|
38 |
| -import ru.yandex.clickhouse.BalancedClickhouseDataSource; |
39 |
| -import ru.yandex.clickhouse.ClickHouseConnection; |
40 |
| -import ru.yandex.clickhouse.response.ClickHouseColumnInfo; |
41 |
| -import ru.yandex.clickhouse.response.ClickHouseResultSetMetaData; |
42 |
| -import ru.yandex.clickhouse.settings.ClickHouseQueryParam; |
43 | 42 |
|
44 | 43 | import javax.annotation.Nullable;
|
45 | 44 |
|
@@ -129,14 +128,11 @@ public void open() throws CatalogException {
|
129 | 128 | try {
|
130 | 129 | Properties configuration = new Properties();
|
131 | 130 | configuration.putAll(properties);
|
132 |
| - configuration.setProperty(ClickHouseQueryParam.USER.getKey(), username); |
133 |
| - configuration.setProperty(ClickHouseQueryParam.PASSWORD.getKey(), password); |
134 |
| - String jdbcUrl = ClickHouseUtil.getJdbcUrl(baseUrl, getDefaultDatabase()); |
135 |
| - BalancedClickhouseDataSource dataSource = |
136 |
| - new BalancedClickhouseDataSource(jdbcUrl, configuration); |
137 |
| - dataSource.actualize(); |
138 |
| - connection = dataSource.getConnection(); |
139 |
| - LOG.info("Created catalog {}, established connection to {}", getName(), jdbcUrl); |
| 131 | + configuration.setProperty(ClickHouseDefaults.USER.getKey(), username); |
| 132 | + configuration.setProperty(ClickHouseDefaults.PASSWORD.getKey(), password); |
| 133 | + ClickHouseDriver driver = new ClickHouseDriver(); |
| 134 | + connection = driver.connect(baseUrl, configuration); |
| 135 | + LOG.info("Created catalog {}, established connection to {}", getName(), baseUrl); |
140 | 136 | } catch (Exception e) {
|
141 | 137 | throw new CatalogException(String.format("Opening catalog %s failed.", getName()), e);
|
142 | 138 | }
|
@@ -307,8 +303,7 @@ private synchronized TableSchema createTableSchema(String databaseName, String t
|
307 | 303 | List<String> primaryKeys = getPrimaryKeys(databaseName, tableName);
|
308 | 304 | TableSchema.Builder builder = TableSchema.builder();
|
309 | 305 | for (int idx = 1; idx <= metaData.getColumnCount(); idx++) {
|
310 |
| - ClickHouseColumnInfo columnInfo = |
311 |
| - (ClickHouseColumnInfo) getColMethod.invoke(metaData, idx); |
| 306 | + ClickHouseColumn columnInfo = (ClickHouseColumn) getColMethod.invoke(metaData, idx); |
312 | 307 | String columnName = columnInfo.getColumnName();
|
313 | 308 | DataType columnType = DataTypeUtil.toFlinkType(columnInfo);
|
314 | 309 | if (primaryKeys.contains(columnName)) {
|
|
0 commit comments