Skip to content

Commit 3cca1c0

Browse files
authored
Destination Snowflake: Use safe executeMetadataQuery call (#37857)
1 parent 3c62abe commit 3cca1c0

File tree

3 files changed

+198
-191
lines changed

3 files changed

+198
-191
lines changed

airbyte-integrations/connectors/destination-snowflake/metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ data:
55
connectorSubtype: database
66
connectorType: destination
77
definitionId: 424892c4-daac-4491-b35d-c6688ba547ba
8-
dockerImageTag: 3.7.1
8+
dockerImageTag: 3.7.2
99
dockerRepository: airbyte/destination-snowflake
1010
documentationUrl: https://docs.airbyte.com/integrations/destinations/snowflake
1111
githubIssueLabel: destination-snowflake

airbyte-integrations/connectors/destination-snowflake/src/main/java/io/airbyte/integrations/destination/snowflake/typing_deduping/SnowflakeDestinationHandler.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,18 @@ private InitialRawTableStatus getInitialRawTableState(final StreamId id, final D
132132
if (destinationSyncMode == DestinationSyncMode.OVERWRITE) {
133133
return new InitialRawTableStatus(false, false, Optional.empty());
134134
}
135-
final ResultSet tables = database.getMetaData().getTables(
136-
databaseName,
137-
id.getRawNamespace(),
138-
id.getRawName(),
139-
null);
140-
if (!tables.next()) {
135+
final boolean tableExists = database.executeMetadataQuery(databaseMetaData -> {
136+
LOGGER.info("Retrieving table from Db metadata: {} {}",
137+
id.getRawNamespace(),
138+
id.getRawName());
139+
try (final ResultSet tables = databaseMetaData.getTables(databaseName, id.getRawNamespace(), id.getRawName(), null)) {
140+
return tables.next();
141+
} catch (SQLException e) {
142+
LOGGER.error("Failed to retrieve table metadata", e);
143+
throw new RuntimeException(e);
144+
}
145+
});
146+
if (!tableExists) {
141147
return new InitialRawTableStatus(false, false, Optional.empty());
142148
}
143149
// Snowflake timestamps have nanosecond precision, so decrement by 1ns

0 commit comments

Comments
 (0)