Skip to content

Commit

Permalink
Destination Snowflake: Use safe executeMetadataQuery call (#37857)
Browse files Browse the repository at this point in the history
  • Loading branch information
gisripa authored May 6, 2024
1 parent 3c62abe commit 3cca1c0
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data:
connectorSubtype: database
connectorType: destination
definitionId: 424892c4-daac-4491-b35d-c6688ba547ba
dockerImageTag: 3.7.1
dockerImageTag: 3.7.2
dockerRepository: airbyte/destination-snowflake
documentationUrl: https://docs.airbyte.com/integrations/destinations/snowflake
githubIssueLabel: destination-snowflake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,18 @@ private InitialRawTableStatus getInitialRawTableState(final StreamId id, final D
if (destinationSyncMode == DestinationSyncMode.OVERWRITE) {
return new InitialRawTableStatus(false, false, Optional.empty());
}
final ResultSet tables = database.getMetaData().getTables(
databaseName,
id.getRawNamespace(),
id.getRawName(),
null);
if (!tables.next()) {
final boolean tableExists = database.executeMetadataQuery(databaseMetaData -> {
LOGGER.info("Retrieving table from Db metadata: {} {}",
id.getRawNamespace(),
id.getRawName());
try (final ResultSet tables = databaseMetaData.getTables(databaseName, id.getRawNamespace(), id.getRawName(), null)) {
return tables.next();
} catch (SQLException e) {
LOGGER.error("Failed to retrieve table metadata", e);
throw new RuntimeException(e);
}
});
if (!tableExists) {
return new InitialRawTableStatus(false, false, Optional.empty());
}
// Snowflake timestamps have nanosecond precision, so decrement by 1ns
Expand Down
Loading

0 comments on commit 3cca1c0

Please sign in to comment.