-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Make schema field in source-snowflake mean a subset of the specified o… #20465
Changes from 2 commits
cb9138b
cad51d3
116be53
4bedc60
55df832
85dbea6
49273e8
6a5d88e
be83996
3ce98b7
898591b
0819c8b
855bc4b
a242f66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
import java.util.Map; | ||
import java.util.Properties; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
@@ -37,8 +38,9 @@ public class SnowflakeDataSourceUtils { | |
public static final String AIRBYTE_OSS = "airbyte_oss"; | ||
public static final String AIRBYTE_CLOUD = "airbyte_cloud"; | ||
private static final String JDBC_CONNECTION_STRING = | ||
"role=%s&warehouse=%s&database=%s&schema=%s&JDBC_QUERY_RESULT_FORMAT=%s&CLIENT_SESSION_KEEP_ALIVE=%s&application=%s"; | ||
"role=%s&warehouse=%s&database=%s&JDBC_QUERY_RESULT_FORMAT=%s&CLIENT_SESSION_KEEP_ALIVE=%s&application=%s"; | ||
|
||
private static final String JDBC_SCHEMA_PARAM = "&schema=%s&CLIENT_METADATA_REQUEST_USE_CONNECTION_CTX=true"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the problem with the current implementation that it does not set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. |
||
private static final Logger LOGGER = LoggerFactory.getLogger(SnowflakeDataSourceUtils.class); | ||
private static final int PAUSE_BETWEEN_TOKEN_REFRESH_MIN = 7; // snowflake access token's TTL is 10min and can't be modified | ||
private static final String REFRESH_TOKEN_URL = "https://%s/oauth/token-request"; | ||
|
@@ -141,13 +143,16 @@ public static String buildJDBCUrl(final JsonNode config, final String airbyteEnv | |
config.get("role").asText(), | ||
config.get("warehouse").asText(), | ||
config.get(JdbcUtils.DATABASE_KEY).asText(), | ||
config.get("schema").asText(), | ||
// Needed for JDK17 - see | ||
// https://stackoverflow.com/questions/67409650/snowflake-jdbc-driver-internal-error-fail-to-retrieve-row-count-for-first-arrow | ||
"JSON", | ||
true, | ||
airbyteEnvironment)); | ||
|
||
if (config.get("schema") != null && StringUtils.isNotBlank(config.get("schema").asText())) { | ||
jdbcUrl.append(JDBC_SCHEMA_PARAM.formatted(config.get("schema").asText())); | ||
} | ||
|
||
// https://docs.snowflake.com/en/user-guide/jdbc-configure.html#jdbc-driver-connection-string | ||
if (config.has(JdbcUtils.JDBC_URL_PARAMS_KEY)) { | ||
jdbcUrl.append("&").append(config.get(JdbcUtils.JDBC_URL_PARAMS_KEY).asText()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes the test more robust in case previous runs left junk schemas or in case multiple instances of acceptance test are running at the same time.