Skip to content

Commit cbb2e98

Browse files
Set app_id in snowflake source connector based on oss/cloud (#19314)
* Set app_id in snowflake source connector based on oss/cloud Set app_id in snowflake source connector based on * Bump version + docs * auto-bump connector version * Formatting Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
1 parent 9161bf9 commit cbb2e98

File tree

10 files changed

+75
-53
lines changed

10 files changed

+75
-53
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
@@ -1343,7 +1343,7 @@
13431343
- name: Snowflake
13441344
sourceDefinitionId: e2d65910-8c8b-40a1-ae7d-ee2416b2bfa2
13451345
dockerRepository: airbyte/source-snowflake
1346-
dockerImageTag: 0.1.25
1346+
dockerImageTag: 0.1.26
13471347
documentationUrl: https://docs.airbyte.com/integrations/sources/snowflake
13481348
icon: snowflake.svg
13491349
sourceType: database

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12728,7 +12728,7 @@
1272812728
- - "client_secret"
1272912729
oauthFlowOutputParameters:
1273012730
- - "refresh_token"
12731-
- dockerImage: "airbyte/source-snowflake:0.1.25"
12731+
- dockerImage: "airbyte/source-snowflake:0.1.26"
1273212732
spec:
1273312733
documentationUrl: "https://docs.airbyte.com/integrations/sources/snowflake"
1273412734
connectionSpecification:

airbyte-integrations/connectors/source-snowflake/Dockerfile

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

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

19-
LABEL io.airbyte.version=0.1.25
19+
LABEL io.airbyte.version=0.1.26
2020
LABEL io.airbyte.name=airbyte/source-snowflake

airbyte-integrations/connectors/source-snowflake/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
application {
9-
mainClass = 'io.airbyte.integrations.source.snowflake.SnowflakeSource'
9+
mainClass = 'io.airbyte.integrations.source.snowflake.SnowflakeSourceRunner'
1010
applicationDefaultJvmArgs = ['-XX:+ExitOnOutOfMemoryError', '-XX:MaxRAMPercentage=75.0']
1111
}
1212

airbyte-integrations/connectors/source-snowflake/src/main/java/io.airbyte.integrations.source.snowflake/SnowflakeDataSourceUtils.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ public class SnowflakeDataSourceUtils {
3434
public static final String OAUTH_METHOD = "OAuth";
3535
public static final String USERNAME_PASSWORD_METHOD = "username/password";
3636
public static final String UNRECOGNIZED = "Unrecognized";
37+
public static final String AIRBYTE_OSS = "airbyte_oss";
38+
public static final String AIRBYTE_CLOUD = "airbyte_cloud";
3739
private static final String JDBC_CONNECTION_STRING =
38-
"role=%s&warehouse=%s&database=%s&schema=%s&JDBC_QUERY_RESULT_FORMAT=%s&CLIENT_SESSION_KEEP_ALIVE=%s&application=Airbyte_Connector";
40+
"role=%s&warehouse=%s&database=%s&schema=%s&JDBC_QUERY_RESULT_FORMAT=%s&CLIENT_SESSION_KEEP_ALIVE=%s&application=%s";
3941

4042
private static final Logger LOGGER = LoggerFactory.getLogger(SnowflakeDataSourceUtils.class);
4143
private static final int PAUSE_BETWEEN_TOKEN_REFRESH_MIN = 7; // snowflake access token's TTL is 10min and can't be modified
@@ -53,9 +55,9 @@ public class SnowflakeDataSourceUtils {
5355
* @param config source config JSON
5456
* @return datasource
5557
*/
56-
public static HikariDataSource createDataSource(final JsonNode config) {
58+
public static HikariDataSource createDataSource(final JsonNode config, final String airbyteEnvironment) {
5759
final HikariDataSource dataSource = new HikariDataSource();
58-
dataSource.setJdbcUrl(buildJDBCUrl(config));
60+
dataSource.setJdbcUrl(buildJDBCUrl(config, airbyteEnvironment));
5961

6062
if (config.has("credentials")) {
6163
final JsonNode credentials = config.get("credentials");
@@ -130,7 +132,7 @@ public static String getAccessTokenUsingRefreshToken(final String hostName,
130132
}
131133
}
132134

133-
public static String buildJDBCUrl(final JsonNode config) {
135+
public static String buildJDBCUrl(final JsonNode config, final String airbyteEnvironment) {
134136
final StringBuilder jdbcUrl = new StringBuilder(String.format("jdbc:snowflake://%s/?",
135137
config.get(JdbcUtils.HOST_KEY).asText()));
136138

@@ -143,7 +145,8 @@ public static String buildJDBCUrl(final JsonNode config) {
143145
// Needed for JDK17 - see
144146
// https://stackoverflow.com/questions/67409650/snowflake-jdbc-driver-internal-error-fail-to-retrieve-row-count-for-first-arrow
145147
"JSON",
146-
true));
148+
true,
149+
airbyteEnvironment));
147150

148151
// https://docs.snowflake.com/en/user-guide/jdbc-configure.html#jdbc-driver-connection-string
149152
if (config.has(JdbcUtils.JDBC_URL_PARAMS_KEY)) {

airbyte-integrations/connectors/source-snowflake/src/main/java/io.airbyte.integrations.source.snowflake/SnowflakeSource.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import io.airbyte.db.jdbc.JdbcUtils;
1717
import io.airbyte.db.jdbc.StreamingJdbcDatabase;
1818
import io.airbyte.db.jdbc.streaming.AdaptiveStreamingQueryConfig;
19-
import io.airbyte.integrations.base.IntegrationRunner;
2019
import io.airbyte.integrations.base.Source;
2120
import io.airbyte.integrations.source.jdbc.AbstractJdbcSource;
2221
import java.io.IOException;
@@ -37,16 +36,11 @@ public class SnowflakeSource extends AbstractJdbcSource<JDBCType> implements Sou
3736
public static final String DRIVER_CLASS = DatabaseDriver.SNOWFLAKE.getDriverClassName();
3837
public static final ScheduledExecutorService SCHEDULED_EXECUTOR_SERVICE = Executors.newScheduledThreadPool(1);
3938

40-
public SnowflakeSource() {
41-
super(DRIVER_CLASS, AdaptiveStreamingQueryConfig::new, new SnowflakeSourceOperations());
42-
}
39+
private final String airbyteEnvironment;
4340

44-
public static void main(final String[] args) throws Exception {
45-
final Source source = new SnowflakeSource();
46-
LOGGER.info("starting source: {}", SnowflakeSource.class);
47-
new IntegrationRunner(source).run(args);
48-
SCHEDULED_EXECUTOR_SERVICE.shutdownNow();
49-
LOGGER.info("completed source: {}", SnowflakeSource.class);
41+
public SnowflakeSource(final String airbyteEnvironment) {
42+
super(DRIVER_CLASS, AdaptiveStreamingQueryConfig::new, new SnowflakeSourceOperations());
43+
this.airbyteEnvironment = airbyteEnvironment;
5044
}
5145

5246
@Override
@@ -59,14 +53,14 @@ public JdbcDatabase createDatabase(final JsonNode config) throws SQLException {
5953

6054
@Override
6155
protected DataSource createDataSource(final JsonNode config) {
62-
final DataSource dataSource = SnowflakeDataSourceUtils.createDataSource(config);
56+
final DataSource dataSource = SnowflakeDataSourceUtils.createDataSource(config, airbyteEnvironment);
6357
dataSources.add(dataSource);
6458
return dataSource;
6559
}
6660

6761
@Override
6862
public JsonNode toDatabaseConfig(final JsonNode config) {
69-
final String jdbcUrl = SnowflakeDataSourceUtils.buildJDBCUrl(config);
63+
final String jdbcUrl = SnowflakeDataSourceUtils.buildJDBCUrl(config, airbyteEnvironment);
7064

7165
if (config.has("credentials")) {
7266
final JsonNode credentials = config.get("credentials");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
*/
4+
5+
package io.airbyte.integrations.source.snowflake;
6+
7+
import static io.airbyte.integrations.source.snowflake.SnowflakeDataSourceUtils.AIRBYTE_CLOUD;
8+
import static io.airbyte.integrations.source.snowflake.SnowflakeDataSourceUtils.AIRBYTE_OSS;
9+
import static io.airbyte.integrations.source.snowflake.SnowflakeSource.SCHEDULED_EXECUTOR_SERVICE;
10+
11+
import io.airbyte.integrations.base.adaptive.AdaptiveSourceRunner;
12+
13+
public class SnowflakeSourceRunner {
14+
15+
public static void main(final String[] args) throws Exception {
16+
AdaptiveSourceRunner.baseOnEnv()
17+
.withOssSource(() -> new SnowflakeSource(AIRBYTE_OSS))
18+
.withCloudSource(() -> new SnowflakeSource(AIRBYTE_CLOUD))
19+
.run(args);
20+
SCHEDULED_EXECUTOR_SERVICE.shutdownNow();
21+
}
22+
23+
}

airbyte-integrations/connectors/source-snowflake/src/test-integration/java/io/airbyte/integrations/io/airbyte/integration_tests/sources/SnowflakeJdbcSourceAcceptanceTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
package io.airbyte.integrations.io.airbyte.integration_tests.sources;
66

7+
import static io.airbyte.integrations.source.snowflake.SnowflakeDataSourceUtils.AIRBYTE_OSS;
78
import static org.junit.jupiter.api.Assertions.assertEquals;
89
import static org.junit.jupiter.api.Assertions.assertTrue;
910

@@ -102,7 +103,7 @@ public String getDriverClass() {
102103

103104
@Override
104105
public AbstractJdbcSource<JDBCType> getJdbcSource() {
105-
return new SnowflakeSource();
106+
return new SnowflakeSource(AIRBYTE_OSS);
106107
}
107108

108109
@Test

airbyte-integrations/connectors/source-snowflake/src/test/java/io/airbyte/integrations/source/snowflake/SnowflakeDataSourceUtilsTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ class SnowflakeDataSourceUtilsTest {
3030
}
3131
""";
3232
private final String expectedJdbcUrl =
33-
"jdbc:snowflake://host/?role=role&warehouse=WAREHOUSE&database=DATABASE&schema=SOURCE_SCHEMA&JDBC_QUERY_RESULT_FORMAT=JSON&CLIENT_SESSION_KEEP_ALIVE=true&application=Airbyte_Connector";
33+
"jdbc:snowflake://host/?role=role&warehouse=WAREHOUSE&database=DATABASE&schema=SOURCE_SCHEMA&JDBC_QUERY_RESULT_FORMAT=JSON&CLIENT_SESSION_KEEP_ALIVE=true&application=airbyte_oss";
3434

3535
@Test
3636
void testBuildJDBCUrl() {
37-
JsonNode expectedConfig = Jsons.deserialize(config);
37+
final JsonNode expectedConfig = Jsons.deserialize(config);
3838

39-
String jdbcURL = SnowflakeDataSourceUtils.buildJDBCUrl(expectedConfig);
39+
final String jdbcURL = SnowflakeDataSourceUtils.buildJDBCUrl(expectedConfig, SnowflakeDataSourceUtils.AIRBYTE_OSS);
4040

4141
assertEquals(expectedJdbcUrl, jdbcURL);
4242
}
4343

4444
@Test
4545
void testBuildJDBCUrlWithParams() {
46-
JsonNode expectedConfig = Jsons.deserialize(config);
47-
String params = "someParameter1&param2=someParameter2";
46+
final JsonNode expectedConfig = Jsons.deserialize(config);
47+
final String params = "someParameter1&param2=someParameter2";
4848
((ObjectNode) expectedConfig).put("jdbc_url_params", params);
4949

50-
String jdbcURL = SnowflakeDataSourceUtils.buildJDBCUrl(expectedConfig);
50+
final String jdbcURL = SnowflakeDataSourceUtils.buildJDBCUrl(expectedConfig, SnowflakeDataSourceUtils.AIRBYTE_OSS);
5151

5252
assertEquals(expectedJdbcUrl + "&" + params, jdbcURL);
5353
}

docs/integrations/sources/snowflake.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,30 @@ To read more please check official [Snowflake documentation](https://docs.snowfl
120120

121121
## Changelog
122122

123-
| Version | Date | Pull Request | Subject |
124-
|:--------|:-----------| :--- | :--- |
123+
| Version | Date | Pull Request | Subject |
124+
| :------ | :--------- |:---------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------|
125+
| 0.1.26 | 2022-11-10 | [19314](https://github.com/airbytehq/airbyte/pull/19314) | Set application id in JDBC URL params based on OSS/Cloud environment |
125126
| 0.1.25 | 2022-11-10 | [15535](https://github.com/airbytehq/airbyte/pull/15535) | Update incremental query to avoid data missing when new data is inserted at the same time as a sync starts under non-CDC incremental mode |
126-
| 0.1.24 | 2022-09-26 | [17144](https://github.com/airbytehq/airbyte/pull/17144) | Fixed bug with incorrect date-time datatypes handling |
127-
| 0.1.23 | 2022-09-26 | [17116](https://github.com/airbytehq/airbyte/pull/17116) | added connection string identifier |
128-
| 0.1.22 | 2022-09-21 | [16766](https://github.com/airbytehq/airbyte/pull/16766) | Update JDBC Driver version to 3.13.22 |
129-
| 0.1.21 | 2022-09-14 | [15668](https://github.com/airbytehq/airbyte/pull/15668) | Wrap logs in AirbyteLogMessage |
130-
| 0.1.20 | 2022-09-01 | [16258](https://github.com/airbytehq/airbyte/pull/16258) | Emit state messages more frequently |
131-
| 0.1.19 | 2022-08-19 | [15797](https://github.com/airbytehq/airbyte/pull/15797) | Allow using role during oauth |
132-
| 0.1.18 | 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 |
133-
| 0.1.17 | 2022-08-09 | [15314](https://github.com/airbytehq/airbyte/pull/15314) | Discover integer columns as integers rather than floats |
134-
| 0.1.16 | 2022-08-04 | [15314](https://github.com/airbytehq/airbyte/pull/15314) | (broken, do not use) Discover integer columns as integers rather than floats |
135-
| 0.1.15 | 2022-07-22 | [14828](https://github.com/airbytehq/airbyte/pull/14828) | Source Snowflake: Source/Destination doesn't respect DATE data type |
136-
| 0.1.14 | 2022-07-22 | [14714](https://github.com/airbytehq/airbyte/pull/14714) | Clarified error message when invalid cursor column selected |
137-
| 0.1.13 | 2022-07-14 | [14574](https://github.com/airbytehq/airbyte/pull/14574) | Removed additionalProperties:false from JDBC source connectors |
138-
| 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 |
139-
| 0.1.11 | 2022-04-27 | [10953](https://github.com/airbytehq/airbyte/pull/10953) | Implement OAuth flow |
140-
| 0.1.9 | 2022-02-21 | [10242](https://github.com/airbytehq/airbyte/pull/10242) | Fixed cursor for old connectors that use non-microsecond format. Now connectors work with both formats |
141-
| 0.1.8 | 2022-02-18 | [10242](https://github.com/airbytehq/airbyte/pull/10242) | Updated timestamp transformation with microseconds |
142-
| 0.1.7 | 2022-02-14 | [10256](https://github.com/airbytehq/airbyte/pull/10256) | Add `-XX:+ExitOnOutOfMemoryError` JVM option |
143-
| 0.1.6 | 2022-01-25 | [9623](https://github.com/airbytehq/airbyte/pull/9623) | Add jdbc_url_params support for optional JDBC parameters |
144-
| 0.1.5 | 2022-01-19 | [9567](https://github.com/airbytehq/airbyte/pull/9567) | Added parameter for keeping JDBC session alive |
145-
| 0.1.4 | 2021-12-30 | [9203](https://github.com/airbytehq/airbyte/pull/9203) | Update connector fields title/description |
146-
| 0.1.3 | 2021-01-11 | [9304](https://github.com/airbytehq/airbyte/pull/9304) | Upgrade version of JDBC driver |
147-
| 0.1.2 | 2021-10-21 | [7257](https://github.com/airbytehq/airbyte/pull/7257) | Fixed parsing of extreme values for FLOAT and NUMBER data types |
148-
| 0.1.1 | 2021-08-13 | [4699](https://github.com/airbytehq/airbyte/pull/4699) | Added json config validator |
127+
| 0.1.24 | 2022-09-26 | [17144](https://github.com/airbytehq/airbyte/pull/17144) | Fixed bug with incorrect date-time datatypes handling |
128+
| 0.1.23 | 2022-09-26 | [17116](https://github.com/airbytehq/airbyte/pull/17116) | added connection string identifier |
129+
| 0.1.22 | 2022-09-21 | [16766](https://github.com/airbytehq/airbyte/pull/16766) | Update JDBC Driver version to 3.13.22 |
130+
| 0.1.21 | 2022-09-14 | [15668](https://github.com/airbytehq/airbyte/pull/15668) | Wrap logs in AirbyteLogMessage |
131+
| 0.1.20 | 2022-09-01 | [16258](https://github.com/airbytehq/airbyte/pull/16258) | Emit state messages more frequently |
132+
| 0.1.19 | 2022-08-19 | [15797](https://github.com/airbytehq/airbyte/pull/15797) | Allow using role during oauth |
133+
| 0.1.18 | 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 |
134+
| 0.1.17 | 2022-08-09 | [15314](https://github.com/airbytehq/airbyte/pull/15314) | Discover integer columns as integers rather than floats |
135+
| 0.1.16 | 2022-08-04 | [15314](https://github.com/airbytehq/airbyte/pull/15314) | (broken, do not use) Discover integer columns as integers rather than floats |
136+
| 0.1.15 | 2022-07-22 | [14828](https://github.com/airbytehq/airbyte/pull/14828) | Source Snowflake: Source/Destination doesn't respect DATE data type |
137+
| 0.1.14 | 2022-07-22 | [14714](https://github.com/airbytehq/airbyte/pull/14714) | Clarified error message when invalid cursor column selected |
138+
| 0.1.13 | 2022-07-14 | [14574](https://github.com/airbytehq/airbyte/pull/14574) | Removed additionalProperties:false from JDBC source connectors |
139+
| 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 |
140+
| 0.1.11 | 2022-04-27 | [10953](https://github.com/airbytehq/airbyte/pull/10953) | Implement OAuth flow |
141+
| 0.1.9 | 2022-02-21 | [10242](https://github.com/airbytehq/airbyte/pull/10242) | Fixed cursor for old connectors that use non-microsecond format. Now connectors work with both formats |
142+
| 0.1.8 | 2022-02-18 | [10242](https://github.com/airbytehq/airbyte/pull/10242) | Updated timestamp transformation with microseconds |
143+
| 0.1.7 | 2022-02-14 | [10256](https://github.com/airbytehq/airbyte/pull/10256) | Add `-XX:+ExitOnOutOfMemoryError` JVM option |
144+
| 0.1.6 | 2022-01-25 | [9623](https://github.com/airbytehq/airbyte/pull/9623) | Add jdbc_url_params support for optional JDBC parameters |
145+
| 0.1.5 | 2022-01-19 | [9567](https://github.com/airbytehq/airbyte/pull/9567) | Added parameter for keeping JDBC session alive |
146+
| 0.1.4 | 2021-12-30 | [9203](https://github.com/airbytehq/airbyte/pull/9203) | Update connector fields title/description |
147+
| 0.1.3 | 2021-01-11 | [9304](https://github.com/airbytehq/airbyte/pull/9304) | Upgrade version of JDBC driver |
148+
| 0.1.2 | 2021-10-21 | [7257](https://github.com/airbytehq/airbyte/pull/7257) | Fixed parsing of extreme values for FLOAT and NUMBER data types |
149+
| 0.1.1 | 2021-08-13 | [4699](https://github.com/airbytehq/airbyte/pull/4699) | Added json config validator |

0 commit comments

Comments
 (0)