Skip to content

Destination ClickHouse: remove tcp port spec parameter #16970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
dockerImageTag: 0.1.12
documentationUrl: https://docs.airbyte.io/integrations/destinations/clickhouse
releaseStage: alpha
icon: cliskhouse.svg
- name: Databricks Lakehouse
destinationDefinitionId: 072d5540-f236-4294-ba7c-ade8fd918496
dockerRepository: airbyte/destination-databricks
Expand Down
22 changes: 6 additions & 16 deletions airbyte-config/init/src/main/resources/seed/destination_specs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -818,53 +818,43 @@
order: 0
port:
title: "Port"
description: "JDBC port (not the native port) of the database."
description: "HTTP port of the database."
type: "integer"
minimum: 0
maximum: 65536
default: 8123
examples:
- "8123"
order: 1
tcp-port:
title: "Native Port"
description: "Native port (not the JDBC) of the database."
type: "integer"
minimum: 0
maximum: 65536
default: 9000
examples:
- "9000"
order: 2
database:
title: "DB Name"
description: "Name of the database."
type: "string"
order: 3
order: 2
username:
title: "User"
description: "Username to use to access the database."
type: "string"
order: 4
order: 3
password:
title: "Password"
description: "Password associated with the username."
type: "string"
airbyte_secret: true
order: 5
order: 4
jdbc_url_params:
description: "Additional properties to pass to the JDBC URL string when\
\ connecting to the database formatted as 'key=value' pairs separated\
\ by the symbol '&'. (example: key1=value1&key2=value2&key3=value3)."
title: "JDBC URL Params"
type: "string"
order: 6
order: 5
ssl:
title: "SSL Connection"
description: "Encrypt data using SSL."
type: "boolean"
default: false
order: 7
order: 6
tunnel_method:
type: "object"
title: "SSH Tunnel Method"
Expand Down
12 changes: 1 addition & 11 deletions airbyte-config/init/src/test/resources/connector_catalog.json
Original file line number Diff line number Diff line change
Expand Up @@ -791,24 +791,14 @@
},
"port": {
"title": "Port",
"description": "JDBC port (not the native port) of the database.",
"description": "HTTP port of the database.",
"type": "integer",
"minimum": 0,
"maximum": 65536,
"default": 8123,
"examples": ["8123"],
"order": 1
},
"tcp-port": {
"title": "Native Port",
"description": "Native port (not the JDBC) of the database.",
"type": "integer",
"minimum": 0,
"maximum": 65536,
"default": 9000,
"examples": ["9000"],
"order": 2
},
"database": {
"title": "DB Name",
"description": "Name of the database.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class JdbcUtils {
public static final String JDBC_URL_PARAMS_KEY = "jdbc_url_params";
public static final String PASSWORD_KEY = "password";
public static final String PORT_KEY = "port";
public static final String TCP_PORT_KEY = "tcp-port";

public static final List<String> PORT_LIST_KEY = List.of("port");
public static final String SCHEMA_KEY = "schema";
// NOTE: this is the plural version of SCHEMA_KEY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
NORMALIZATION_TEST_MYSQL_DB_PORT = "NORMALIZATION_TEST_MYSQL_DB_PORT"
NORMALIZATION_TEST_POSTGRES_DB_PORT = "NORMALIZATION_TEST_POSTGRES_DB_PORT"
NORMALIZATION_TEST_CLICKHOUSE_DB_PORT = "NORMALIZATION_TEST_CLICKHOUSE_DB_PORT"
NORMALIZATION_TEST_CLICKHOUSE_DB_TCP_PORT = "NORMALIZATION_TEST_CLICKHOUSE_DB_TCP_PORT"
NORMALIZATION_TEST_TIDB_DB_PORT = "NORMALIZATION_TEST_TIDB_DB_PORT"


Expand Down Expand Up @@ -224,28 +223,20 @@ def setup_mssql_db(self):

def setup_clickhouse_db(self):
"""
ClickHouse official JDBC driver use HTTP port 8123, while Python ClickHouse
driver uses native port 9000, so we need to open both ports for destination
connector and dbt container respectively.
ClickHouse official JDBC driver uses HTTP port 8123.

Ref: https://altinity.com/blog/2019/3/15/clickhouse-networking-part-1
"""
start_db = True
port = 8123
tcp_port = 9000
if os.getenv(NORMALIZATION_TEST_CLICKHOUSE_DB_PORT):
port = int(os.getenv(NORMALIZATION_TEST_CLICKHOUSE_DB_PORT))
start_db = False
if os.getenv(NORMALIZATION_TEST_CLICKHOUSE_DB_TCP_PORT):
tcp_port = int(os.getenv(NORMALIZATION_TEST_CLICKHOUSE_DB_TCP_PORT))
start_db = False
if start_db:
port = self.find_free_port()
tcp_port = self.find_free_port()
config = {
"host": "localhost",
"port": port,
"tcp-port": tcp_port,
"database": self.target_schema,
"username": "default",
"password": "",
Expand All @@ -263,8 +254,6 @@ def setup_clickhouse_db(self):
"--ulimit",
"nofile=262144:262144",
"-p",
f"{config['tcp-port']}:9000", # Python clickhouse driver use native port
"-p",
f"{config['port']}:8123", # clickhouse JDBC driver use HTTP port
"-d",
# so far, only the latest version ClickHouse server image turned on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,6 @@ def transform_clickhouse(config: Dict[str, Any]):
}
if "password" in config:
dbt_config["password"] = config["password"]
if "tcp-port" in config:
dbt_config["port"] = config["tcp-port"]
return dbt_config

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ protected String getDefaultSchema(final JsonNode config) {
protected JsonNode getConfig() {
return Jsons.jsonNode(ImmutableMap.builder()
.put(JdbcUtils.HOST_KEY, HostPortResolver.resolveIpAddress(db))
.put(JdbcUtils.TCP_PORT_KEY, NATIVE_SECURE_PORT)
.put(JdbcUtils.PORT_KEY, HTTPS_PORT)
.put(JdbcUtils.DATABASE_KEY, DB_NAME)
.put(JdbcUtils.USERNAME_KEY, USER_NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,48 +19,38 @@
},
"port": {
"title": "Port",
"description": "JDBC port (not the native port) of the database.",
"description": "HTTP port of the database.",
"type": "integer",
"minimum": 0,
"maximum": 65536,
"default": 8123,
"examples": ["8123"],
"order": 1
},
"tcp-port": {
"title": "Native Port",
"description": "Native port (not the JDBC) of the database.",
"type": "integer",
"minimum": 0,
"maximum": 65536,
"default": 9000,
"examples": ["9000"],
"order": 2
},
"database": {
"title": "DB Name",
"description": "Name of the database.",
"type": "string",
"order": 3
"order": 2
},
"username": {
"title": "User",
"description": "Username to use to access the database.",
"type": "string",
"order": 4
"order": 3
},
"password": {
"title": "Password",
"description": "Password associated with the username.",
"type": "string",
"airbyte_secret": true,
"order": 5
"order": 4
},
"jdbc_url_params": {
"description": "Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (example: key1=value1&key2=value2&key3=value3).",
"title": "JDBC URL Params",
"type": "string",
"order": 6
"order": 5
},
"tunnel_method": {
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@ This destination connector uses ClickHouse official JDBC driver, which uses HTTP

## Quick Notes

- ClickHouse JDBC driver uses HTTP protocal (default 8123) but [dbt clickhouse adapter](https://github.com/silentsokolov/dbt-clickhouse) use TCP protocal (default 9000).

- This connector doesn't support nested streams and schema change yet.

- The community [dbt clickhouse adapter](https://github.com/silentsokolov/dbt-clickhouse) has some bugs haven't been fixed yet, for example [https://github.com/silentsokolov/dbt-clickhouse/issues/20](https://github.com/silentsokolov/dbt-clickhouse/issues/20), so the dbt test is based on a fork [https://github.com/burmecia/dbt-clickhouse](https://github.com/burmecia/dbt-clickhouse).

## API Reference

The ClickHouse reference documents: [https://clickhouse.com/docs/en/](https://clickhouse.com/docs/en/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,55 +19,45 @@
},
"port": {
"title": "Port",
"description": "JDBC port (not the native port) of the database.",
"description": "HTTP port of the database.",
"type": "integer",
"minimum": 0,
"maximum": 65536,
"default": 8123,
"examples": ["8123"],
"order": 1
},
"tcp-port": {
"title": "Native Port",
"description": "Native port (not the JDBC) of the database.",
"type": "integer",
"minimum": 0,
"maximum": 65536,
"default": 9000,
"examples": ["9000"],
"order": 2
},
"database": {
"title": "DB Name",
"description": "Name of the database.",
"type": "string",
"order": 3
"order": 2
},
"username": {
"title": "User",
"description": "Username to use to access the database.",
"type": "string",
"order": 4
"order": 3
},
"password": {
"title": "Password",
"description": "Password associated with the username.",
"type": "string",
"airbyte_secret": true,
"order": 5
"order": 4
},
"jdbc_url_params": {
"description": "Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (example: key1=value1&key2=value2&key3=value3).",
"title": "JDBC URL Params",
"type": "string",
"order": 6
"order": 5
},
"ssl": {
"title": "SSL Connection",
"description": "Encrypt data using SSL.",
"type": "boolean",
"default": false,
"order": 7
"order": 6
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,9 @@ protected String getDefaultSchema(final JsonNode config) {

@Override
protected JsonNode getConfig() {
final Optional tcpPort = db.getExposedPorts().stream()
.map(exPort -> db.getMappedPort((Integer) exPort))
.filter(el -> !db.getFirstMappedPort().equals(el))
.findFirst();

return Jsons.jsonNode(ImmutableMap.builder()
.put(JdbcUtils.HOST_KEY, HostPortResolver.resolveHost(db))
.put(JdbcUtils.PORT_KEY, HostPortResolver.resolvePort(db))
.put(JdbcUtils.TCP_PORT_KEY, tcpPort.get())
.put(JdbcUtils.DATABASE_KEY, DB_NAME)
.put(JdbcUtils.USERNAME_KEY, db.getUsername())
.put(JdbcUtils.PASSWORD_KEY, db.getPassword())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected String getDefaultSchema(final JsonNode config) {
@Override
protected JsonNode getConfig() throws Exception {
return bastion.getTunnelConfig(getTunnelMethod(), bastion.getBasicDbConfigBuider(db, DB_NAME)
.put("schema", DB_NAME).put(JdbcUtils.TCP_PORT_KEY, 9000));
.put("schema", DB_NAME));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class ClickhouseDestinationSpecTest {
+ "\"username\" : \"clickhouse\", "
+ "\"database\" : \"clickhouse_db\", "
+ "\"port\" : 8123, "
+ "\"tcp-port\" : 9000, "
+ "\"host\" : \"localhost\", "
+ "\"jdbc_url_params\" : \"property1=pValue1&property2=pValue2\", "
+ "\"ssl\" : true "
Expand Down
3 changes: 1 addition & 2 deletions docs/integrations/destinations/clickhouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ You will need to choose an existing database or create a new database that will
You should now have all the requirements needed to configure ClickHouse as a destination in the UI. You'll need the following information to configure the ClickHouse destination:

* **Host**
* **Port** (JDBC HTTP port, not the native port)
* **Tcp-port** (Native port, also required for data normalization)
* **Port**
* **Username**
* **Password**
* **Database**
Expand Down