Skip to content

Commit c85e131

Browse files
authored
🎉Source-postgres: added custom JDBC parameters (jdbc_url_params) field (#12840)
* [10729] source-postgres: added custom JDBC parameters field
1 parent ec8c8c6 commit c85e131

File tree

7 files changed

+40
-7
lines changed

7 files changed

+40
-7
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@
715715
- name: Postgres
716716
sourceDefinitionId: decd338e-5647-4c0b-adf4-da0e75f5a750
717717
dockerRepository: airbyte/source-postgres
718-
dockerImageTag: 0.4.15
718+
dockerImageTag: 0.4.16
719719
documentationUrl: https://docs.airbyte.io/integrations/sources/postgres
720720
icon: postgresql.svg
721721
sourceType: database

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -6545,7 +6545,7 @@
65456545
supportsNormalization: false
65466546
supportsDBT: false
65476547
supported_destination_sync_modes: []
6548-
- dockerImage: "airbyte/source-postgres:0.4.15"
6548+
- dockerImage: "airbyte/source-postgres:0.4.16"
65496549
spec:
65506550
documentationUrl: "https://docs.airbyte.com/integrations/sources/postgres"
65516551
connectionSpecification:
@@ -6601,17 +6601,24 @@
66016601
type: "string"
66026602
airbyte_secret: true
66036603
order: 5
6604+
jdbc_url_params:
6605+
description: "Additional properties to pass to the JDBC URL string when\
6606+
\ connecting to the database formatted as 'key=value' pairs separated\
6607+
\ by the symbol '&'. (example: key1=value1&key2=value2&key3=value3)."
6608+
title: "JDBC URL Params"
6609+
type: "string"
6610+
order: 6
66046611
ssl:
66056612
title: "Connect using SSL"
66066613
description: "Encrypt client/server communications for increased security."
66076614
type: "boolean"
66086615
default: false
6609-
order: 6
6616+
order: 7
66106617
replication_method:
66116618
type: "object"
66126619
title: "Replication Method"
66136620
description: "Replication method to use for extracting data from the database."
6614-
order: 7
6621+
order: 8
66156622
oneOf:
66166623
- title: "Standard"
66176624
additionalProperties: false

‎airbyte-integrations/connectors/source-postgres/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ ENV APPLICATION source-postgres
1616

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

19-
LABEL io.airbyte.version=0.4.15
19+
LABEL io.airbyte.version=0.4.16
2020
LABEL io.airbyte.name=airbyte/source-postgres

‎airbyte-integrations/connectors/source-postgres/src/main/java/io/airbyte/integrations/source/postgres/PostgresSource.java

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ public JsonNode toDatabaseConfigStatic(final JsonNode config) {
7979
config.get("port").asText(),
8080
config.get("database").asText()));
8181

82+
if (config.get("jdbc_url_params") != null && !config.get("jdbc_url_params").asText().isEmpty()) {
83+
jdbcUrl.append(config.get("jdbc_url_params").asText()).append("&");
84+
}
85+
8286
// assume ssl if not explicitly mentioned.
8387
if (!config.has("ssl") || config.get("ssl").asBoolean()) {
8488
additionalParameters.add("ssl=true");

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,24 @@
5454
"airbyte_secret": true,
5555
"order": 5
5656
},
57+
"jdbc_url_params": {
58+
"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).",
59+
"title": "JDBC URL Params",
60+
"type": "string",
61+
"order": 6
62+
},
5763
"ssl": {
5864
"title": "Connect using SSL",
5965
"description": "Encrypt client/server communications for increased security.",
6066
"type": "boolean",
6167
"default": false,
62-
"order": 6
68+
"order": 7
6369
},
6470
"replication_method": {
6571
"type": "object",
6672
"title": "Replication Method",
6773
"description": "Replication method to use for extracting data from the database.",
68-
"order": 7,
74+
"order": 8,
6975
"oneOf": [
7076
{
7177
"title": "Standard",

‎airbyte-integrations/connectors/source-postgres/src/test/java/io/airbyte/integrations/source/postgres/PostgresSpecTest.java

+15
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
package io.airbyte.integrations.source.postgres;
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;
1112
import com.fasterxml.jackson.databind.node.ObjectNode;
1213
import io.airbyte.commons.io.IOs;
1314
import io.airbyte.commons.json.Jsons;
1415
import io.airbyte.commons.resources.MoreResources;
16+
import io.airbyte.protocol.models.ConnectorSpecification;
1517
import io.airbyte.validation.json.JsonSchemaValidator;
1618
import java.io.File;
1719
import java.io.IOException;
@@ -33,6 +35,7 @@ public class PostgresSpecTest {
3335
+ "\"schemas\" : [\"public\"], "
3436
+ "\"port\" : 5432, "
3537
+ "\"host\" : \"localhost\", "
38+
+ "\"jdbc_url_params\" : \"property1=pValue1&property2=pValue2\", "
3639
+ "\"ssl\" : true, "
3740
+ "\"replication_method\" : { \"method\" : \"CDC\", \"replication_slot\" : \"ab_slot\", \"publication\" : \"ab_publication\" }"
3841
+ "}";
@@ -112,4 +115,16 @@ void testWithReplicationMethodWithReplicationSlotWithNull() {
112115
assertFalse(validator.test(schema, config));
113116
}
114117

118+
@Test
119+
void testWithJdbcAdditionalProperty() {
120+
final JsonNode config = Jsons.deserialize(CONFIGURATION);
121+
assertTrue(validator.test(schema, config));
122+
}
123+
124+
@Test
125+
void testJdbcAdditionalProperty() throws Exception {
126+
final ConnectorSpecification spec = new PostgresSource().spec();
127+
assertNotNull(spec.getConnectionSpecification().get("properties").get("jdbc_url_params"));
128+
}
129+
115130
}

‎docs/integrations/sources/postgres.md

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ According to Postgres [documentation](https://www.postgresql.org/docs/14/datatyp
270270

271271
| Version | Date | Pull Request | Subject |
272272
|:--------|:-----------|:-------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------|
273+
| 0.4.16 | 2022-05-14 | [12840](https://github.com/airbytehq/airbyte/pull/12840) | Added custom JDBC parameters field |
273274
| 0.4.15 | 2022-05-13 | [12834](https://github.com/airbytehq/airbyte/pull/12834) | Fix the bug that the connector returns empty catalog for Azure Postgres database |
274275
| 0.4.14 | 2022-05-08 | [12689](https://github.com/airbytehq/airbyte/pull/12689) | Add table retrieval according to role-based `SELECT` privilege |
275276
| 0.4.13 | 2022-05-05 | [10230](https://github.com/airbytehq/airbyte/pull/10230) | Explicitly set null value for field in json |

0 commit comments

Comments
 (0)