Skip to content

Commit 479c232

Browse files
authored
🎉Source-cockroachdb: added custom JDBC parameters field (#16394)
* [10723] Source-cockroachdb: added custom JDBC parameters field
1 parent 086d33e commit 479c232

File tree

9 files changed

+50
-7
lines changed

9 files changed

+50
-7
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
- name: Cockroachdb
185185
sourceDefinitionId: 9fa5862c-da7c-11eb-8d19-0242ac130003
186186
dockerRepository: airbyte/source-cockroachdb
187-
dockerImageTag: 0.1.17
187+
dockerImageTag: 0.1.18
188188
documentationUrl: https://docs.airbyte.io/integrations/sources/cockroachdb
189189
icon: cockroachdb.svg
190190
sourceType: database

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,7 @@
17951795
supportsNormalization: false
17961796
supportsDBT: false
17971797
supported_destination_sync_modes: []
1798-
- dockerImage: "airbyte/source-cockroachdb:0.1.17"
1798+
- dockerImage: "airbyte/source-cockroachdb:0.1.18"
17991799
spec:
18001800
documentationUrl: "https://docs.airbyte.io/integrations/sources/cockroachdb"
18011801
connectionSpecification:
@@ -1839,12 +1839,21 @@
18391839
type: "string"
18401840
airbyte_secret: true
18411841
order: 4
1842+
jdbc_url_params:
1843+
description: "Additional properties to pass to the JDBC URL string when\
1844+
\ connecting to the database formatted as 'key=value' pairs separated\
1845+
\ by the symbol '&'. (Eg. key1=value1&key2=value2&key3=value3). For more\
1846+
\ information read about <a href=\"https://jdbc.postgresql.org/documentation/head/connect.html\"\
1847+
>JDBC URL parameters</a>."
1848+
title: "JDBC URL Parameters (Advanced)"
1849+
type: "string"
1850+
order: 5
18421851
ssl:
18431852
title: "Connect using SSL"
18441853
description: "Encrypt client/server communications for increased security."
18451854
type: "boolean"
18461855
default: false
1847-
order: 5
1856+
order: 6
18481857
supportsNormalization: false
18491858
supportsDBT: false
18501859
supported_destination_sync_modes: []

airbyte-integrations/connectors/source-cockroachdb-strict-encrypt/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ ENV APPLICATION source-cockroachdb-strict-encrypt
1616

1717
COPY --from=build /airbyte /airbyte
1818

19-
LABEL io.airbyte.version=0.1.17
19+
LABEL io.airbyte.version=0.1.18
2020
LABEL io.airbyte.name=airbyte/source-cockroachdb-strict-encrypt

airbyte-integrations/connectors/source-cockroachdb-strict-encrypt/src/main/resources/expected_spec.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@
4040
"type": "string",
4141
"airbyte_secret": true,
4242
"order": 4
43+
},
44+
"jdbc_url_params": {
45+
"description": "Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (Eg. key1=value1&key2=value2&key3=value3). For more information read about <a href=\"https://jdbc.postgresql.org/documentation/head/connect.html\">JDBC URL parameters</a>.",
46+
"title": "JDBC URL Parameters (Advanced)",
47+
"type": "string",
48+
"order": 5
4349
}
4450
}
4551
}

airbyte-integrations/connectors/source-cockroachdb/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ ENV APPLICATION source-cockroachdb
1616

1717
COPY --from=build /airbyte /airbyte
1818

19-
LABEL io.airbyte.version=0.1.17
19+
LABEL io.airbyte.version=0.1.18
2020
LABEL io.airbyte.name=airbyte/source-cockroachdb

airbyte-integrations/connectors/source-cockroachdb/src/main/java/io/airbyte/integrations/source/cockroachdb/CockroachDbSource.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
package io.airbyte.integrations.source.cockroachdb;
66

7+
import static io.airbyte.db.jdbc.JdbcUtils.AMPERSAND;
8+
79
import com.fasterxml.jackson.databind.JsonNode;
810
import com.google.common.collect.ImmutableMap;
911
import io.airbyte.commons.functional.CheckedFunction;
@@ -61,6 +63,10 @@ public JsonNode toDatabaseConfig(final JsonNode config) {
6163
config.get(JdbcUtils.PORT_KEY).asText(),
6264
config.get(JdbcUtils.DATABASE_KEY).asText()));
6365

66+
if (config.get(JdbcUtils.JDBC_URL_PARAMS_KEY) != null && !config.get(JdbcUtils.JDBC_URL_PARAMS_KEY).asText().isEmpty()) {
67+
jdbcUrl.append(config.get(JdbcUtils.JDBC_URL_PARAMS_KEY).asText()).append(AMPERSAND);
68+
}
69+
6470
if (config.has(JdbcUtils.SSL_KEY) && config.get(JdbcUtils.SSL_KEY).asBoolean() || !config.has(JdbcUtils.SSL_KEY)) {
6571
additionalParameters.add("ssl=true");
6672
additionalParameters.add("sslmode=require");

airbyte-integrations/connectors/source-cockroachdb/src/main/resources/spec.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@
4141
"airbyte_secret": true,
4242
"order": 4
4343
},
44+
"jdbc_url_params": {
45+
"description": "Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (Eg. key1=value1&key2=value2&key3=value3). For more information read about <a href=\"https://jdbc.postgresql.org/documentation/head/connect.html\">JDBC URL parameters</a>.",
46+
"title": "JDBC URL Parameters (Advanced)",
47+
"type": "string",
48+
"order": 5
49+
},
4450
"ssl": {
4551
"title": "Connect using SSL",
4652
"description": "Encrypt client/server communications for increased security.",
4753
"type": "boolean",
4854
"default": false,
49-
"order": 5
55+
"order": 6
5056
}
5157
}
5258
}

airbyte-integrations/connectors/source-cockroachdb/src/test/java/io/airbyte/integrations/source/cockroachdb/CockroachDbSpecTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package io.airbyte.integrations.source.cockroachdb;
66

77
import static org.junit.jupiter.api.Assertions.assertFalse;
8+
import static org.junit.jupiter.api.Assertions.assertNotNull;
89
import static org.junit.jupiter.api.Assertions.assertTrue;
910

1011
import com.fasterxml.jackson.databind.JsonNode;
@@ -13,6 +14,7 @@
1314
import io.airbyte.commons.json.Jsons;
1415
import io.airbyte.commons.resources.MoreResources;
1516
import io.airbyte.db.jdbc.JdbcUtils;
17+
import io.airbyte.protocol.models.ConnectorSpecification;
1618
import io.airbyte.validation.json.JsonSchemaValidator;
1719
import java.io.File;
1820
import java.io.IOException;
@@ -33,6 +35,7 @@ public class CockroachDbSpecTest {
3335
+ "\"database\" : \"postgres_db\", "
3436
+ "\"port\" : 5432, "
3537
+ "\"host\" : \"localhost\", "
38+
+ "\"jdbc_url_params\" : \"property1=pValue1&property2=pValue2\", "
3639
+ "\"ssl\" : true }";
3740

3841
private static JsonNode schema;
@@ -69,4 +72,16 @@ void testWithReplicationMethodWithReplicationSlot() {
6972
assertTrue(validator.test(schema, config));
7073
}
7174

75+
@Test
76+
void testWithJdbcAdditionalProperty() {
77+
final JsonNode config = Jsons.deserialize(CONFIGURATION);
78+
assertTrue(validator.test(schema, config));
79+
}
80+
81+
@Test
82+
void testJdbcAdditionalProperty() throws Exception {
83+
final ConnectorSpecification spec = new CockroachDbSource().spec();
84+
assertNotNull(spec.getConnectionSpecification().get("properties").get("jdbc_url_params"));
85+
}
86+
7287
}

docs/integrations/sources/cockroachdb.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,10 @@ Your database user should now be ready for use with Airbyte.
9595

9696
| Version | Date | Pull Request | Subject |
9797
|:--------|:-----------| :--- | :--- |
98+
| 0.1.18 | 2022-09-01 | [16394](https://github.com/airbytehq/airbyte/pull/16394) | Added custom jdbc properties field |
9899
| 0.1.17 | 2022-09-01 | [16238](https://github.com/airbytehq/airbyte/pull/16238) | Emit state messages more frequently |
99100
| 0.1.16 | 2022-08-18 | [14356](https://github.com/airbytehq/airbyte/pull/14356) | DB Sources: only show a table can sync incrementally if at least one column can be used as a cursor field |
100-
| 0.1.13 | 2022-07-14 | [14574](https://github.com/airbytehq/airbyte/pull/14574) | Removed additionalProperties:false from JDBC source connectors |
101+
| 0.1.13 | 2022-07-14 | [14574](https://github.com/airbytehq/airbyte/pull/14574) | Removed additionalProperties:false from JDBC source connectors |
101102
| 0.1.12 | 2022-04-29 | [12480](https://github.com/airbytehq/airbyte/pull/12480) | Query tables with adaptive fetch size to optimize JDBC memory consumption |
102103
| 0.1.11 | 2022-04-06 | [11729](https://github.com/airbytehq/airbyte/pull/11729) | Bump mina-sshd from 2.7.0 to 2.8.0 |
103104
| 0.1.10 | 2022-02-24 | [10235](https://github.com/airbytehq/airbyte/pull/10235) | Fix Replication Failure due Multiple portal opens |

0 commit comments

Comments
 (0)