Skip to content

Commit

Permalink
feat: Add options to clickhouse client (#2465)
Browse files Browse the repository at this point in the history
* feat: Add options to clickhouse client

* fix test
  • Loading branch information
karolisg authored Mar 23, 2024
1 parent 9c13ed6 commit 8d4a3c5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dozer-sink-clickhouse/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,14 @@ impl ClickhouseClient {
None => config.user.to_string(),
};

let options = config
.options
.iter()
.map(|(k, v)| format!("{}={}", k, v))
.collect::<Vec<String>>()
.join("&");
let url = format!(
"{}://{}@{}:{}/{}",
"{}://{}@{}:{}/{}?{options}",
config.scheme, user_password, config.host, config.port, config.database
);
debug!("{url}");
Expand Down
1 change: 1 addition & 0 deletions dozer-sink-clickhouse/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn get_sink_config() -> ClickhouseSinkConfig {
database: "default".to_string(),
host: "localhost".to_string(),
port: 9000,
options: vec![],
}
}

Expand Down
1 change: 1 addition & 0 deletions dozer-types/src/models/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub struct ClickhouseSinkConfig {
pub scheme: String,
#[serde(default = "ClickhouseSinkConfig::default_database")]
pub database: String,
pub options: Vec<(String, String)>,
pub source_table_name: String,
pub sink_table_name: String,
pub create_table_options: Option<ClickhouseTableOptions>,
Expand Down
17 changes: 17 additions & 0 deletions json_schemas/dozer.json
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@
"ClickhouseSinkConfig": {
"type": "object",
"required": [
"options",
"sink_table_name",
"source_table_name"
],
Expand All @@ -431,6 +432,22 @@
"default": "0.0.0.0",
"type": "string"
},
"options": {
"type": "array",
"items": {
"type": "array",
"items": [
{
"type": "string"
},
{
"type": "string"
}
],
"maxItems": 2,
"minItems": 2
}
},
"password": {
"default": null,
"type": [
Expand Down

0 comments on commit 8d4a3c5

Please sign in to comment.