Skip to content

Commit

Permalink
6339: error when attempting to use azure sql database within an elast…
Browse files Browse the repository at this point in the history
…ic pool as source for cdc based replication (#13866)

* 6339: debug info

* 6339: not using 'USE' on Azure SQL servers

* 6339: cleanup

* 6339: cleanup2

* 6339: cleanup3

* 6339: versions/changelogs updated

* 6339: merge from master (consolidation issue)

* 6339: dev connector version (for testing in airbyte cloud)

* 6339: code review implementation

* 6339: apply formatting
  • Loading branch information
kimerinn authored Jun 22, 2022
1 parent f69a78c commit 0d870bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-mssql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION source-mssql

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=0.4.3
LABEL io.airbyte.version=0.4.4
LABEL io.airbyte.name=airbyte/source-mssql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import java.io.File;
import java.sql.JDBCType;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -275,7 +277,17 @@ protected void assertCdcEnabledInDb(final JsonNode config, final JdbcDatabase da
protected void assertCdcSchemaQueryable(final JsonNode config, final JdbcDatabase database)
throws SQLException {
final List<JsonNode> queryResponse = database.queryJsons(connection -> {
final String sql = "USE " + config.get("database").asText() + "; SELECT * FROM cdc.change_tables";
boolean isAzureSQL = false;

try (Statement stmt = connection.createStatement();
ResultSet editionRS = stmt.executeQuery("SELECT ServerProperty('Edition')")) {
isAzureSQL = editionRS.next() && "SQL Azure".equals(editionRS.getString(1));
}

// Azure SQL does not support USE clause
final String sql =
isAzureSQL ? "SELECT * FROM cdc.change_tables" : "USE " + config.get("database").asText() + "; SELECT * FROM cdc.change_tables";

final PreparedStatement ps = connection.prepareStatement(sql);
LOGGER.info(String.format(
"Checking user '%s' can query the cdc schema and that we have at least 1 cdc enabled table using the query: '%s'",
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ If you do not see a type in this list, assume that it is coerced into a string.

| Version | Date | Pull Request | Subject |
|:--------|:-----------| :----------------------------------------------------- |:-------------------------------------------------------------------------------------------------------|
| 0.4.4 | 2022-07-20 | [13866](https://github.com/airbytehq/airbyte/pull/13866) | Omit using 'USE' keyword on Azure SQL with CDC |
| 0.4.3 | 2022-07-17 | [13887](https://github.com/airbytehq/airbyte/pull/13887) | Increase version to include changes from [13854](https://github.com/airbytehq/airbyte/pull/13854) |
| 0.4.2 | 2022-06-06 | [13435](https://github.com/airbytehq/airbyte/pull/13435) | Adjust JDBC fetch size based on max memory and max row size |
| 0.4.1 | 2022-05-25 | [13419](https://github.com/airbytehq/airbyte/pull/13419) | Correct enum for Standard method. |
Expand Down

0 comments on commit 0d870bd

Please sign in to comment.