Skip to content

Commit

Permalink
馃悰 Fix handling binary data type for Mssql source (#7748)
Browse files Browse the repository at this point in the history
* Fix data type tests Mssql source

* update test for boolean data type in  Mysql source

* dump versions for Mssql and Mysql source

* revert changes regarding handling bit data type

* revert changes regarding date and time data type tests Mssql source

* revert changes regarding date data type for Mssql source

* update message in mssql.md

* minor format changes

* format changes
  • Loading branch information
sashaNeshcheret committed Nov 11, 2021
1 parent bea9bb5 commit 70ed18b
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"sourceDefinitionId": "b5ea17b1-f170-46dc-bc31-cc744ca984c1",
"name": "Microsoft SQL Server (MSSQL)",
"dockerRepository": "airbyte/source-mssql",
"dockerImageTag": "0.3.8",
"dockerImageTag": "0.3.9",
"documentationUrl": "https://docs.airbyte.io/integrations/sources/mssql",
"icon": "mssql.svg"
}
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
- name: Microsoft SQL Server (MSSQL)
sourceDefinitionId: b5ea17b1-f170-46dc-bc31-cc744ca984c1
dockerRepository: airbyte/source-mssql
dockerImageTag: 0.3.6
dockerImageTag: 0.3.9
documentationUrl: https://docs.airbyte.io/integrations/sources/mssql
icon: mssql.svg
sourceType: database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3198,7 +3198,7 @@
supportsNormalization: false
supportsDBT: false
supported_destination_sync_modes: []
- dockerImage: "airbyte/source-mssql:0.3.6"
- dockerImage: "airbyte/source-mssql:0.3.9"
spec:
documentationUrl: "https://docs.airbyte.io/integrations/destinations/mssql"
connectionSpecification:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public JdbcDatabase createDatabase(final JsonNode config) throws SQLException {
}

protected JdbcSourceOperations getSourceOperations() {
return JdbcUtils.getDefaultSourceOperations();
return sourceOperations;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ COPY build/distributions/${APPLICATION}*.tar ${APPLICATION}.tar

RUN tar xf ${APPLICATION}.tar --strip-components=1

LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.version=0.1.2
LABEL io.airbyte.name=airbyte/source-mssql-strict-encrypt
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-mssql/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ COPY build/distributions/${APPLICATION}*.tar ${APPLICATION}.tar

RUN tar xf ${APPLICATION}.tar --strip-components=1

LABEL io.airbyte.version=0.3.8
LABEL io.airbyte.version=0.3.9
LABEL io.airbyte.name=airbyte/source-mssql
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import io.airbyte.commons.json.Jsons;
import io.airbyte.commons.util.AutoCloseableIterator;
import io.airbyte.db.jdbc.JdbcDatabase;
import io.airbyte.db.jdbc.JdbcSourceOperations;
import io.airbyte.db.jdbc.JdbcUtils;
import io.airbyte.integrations.base.IntegrationRunner;
import io.airbyte.integrations.base.Source;
import io.airbyte.integrations.base.ssh.SshWrappedSource;
Expand Down Expand Up @@ -55,15 +53,12 @@ public class MssqlSource extends AbstractJdbcSource implements Source {
public static final List<String> HOST_KEY = List.of("host");
public static final List<String> PORT_KEY = List.of("port");

private final JdbcSourceOperations sourceOperations;

public static Source sshWrappedSource() {
return new SshWrappedSource(new MssqlSource(), HOST_KEY, PORT_KEY);
}

MssqlSource() {
super(DRIVER_CLASS, new MssqlJdbcStreamingQueryConfiguration());
this.sourceOperations = JdbcUtils.getDefaultSourceOperations();
super(DRIVER_CLASS, new MssqlJdbcStreamingQueryConfiguration(), new MssqlSourceOperations());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2021 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.integrations.source.mssql;

import com.fasterxml.jackson.databind.node.ObjectNode;
import io.airbyte.db.jdbc.JdbcSourceOperations;
import java.sql.ResultSet;
import java.sql.SQLException;

public class MssqlSourceOperations extends JdbcSourceOperations {

protected void putBinary(final ObjectNode node, final String columnName, final ResultSet resultSet, final int index) throws SQLException {
byte[] bytes = resultSet.getBytes(index);
String value = new String(bytes);
node.put(columnName, value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ protected void initTests() {
.airbyteType(JsonSchemaPrimitive.NUMBER)
.addInsertValues("null", "0", "1", "'true'", "'false'")
.addExpectedValues(null, "false", "true", "true", "false")
.addInsertValues("null")
.addNullExpectedValue()
.build());

addDataTypeTestData(
Expand Down Expand Up @@ -285,27 +283,21 @@ protected void initTests() {
null, "\\xF0\\x9F\\x9A\\x80")
.build());

// TODO BUG Returns binary value instead of actual value
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("binary")
.airbyteType(JsonSchemaPrimitive.STRING)
// .addInsertValues("CAST( 'A' AS VARBINARY)", "null")
// .addExpectedValues("A")
.addInsertValues("null")
.addNullExpectedValue()
.addInsertValues("CAST( 'A' AS BINARY(1))", "null")
.addExpectedValues("A", null)
.build());

// TODO BUG Returns binary value instead of actual value
addDataTypeTestData(
TestDataHolder.builder()
.sourceType("varbinary")
.fullSourceDataType("varbinary(30)")
.fullSourceDataType("varbinary(3)")
.airbyteType(JsonSchemaPrimitive.STRING)
// .addInsertValues("CAST( 'ABC' AS VARBINARY)", "null")
// .addExpectedValues("A")
.addInsertValues("null")
.addNullExpectedValue()
.addInsertValues("CAST( 'ABC' AS VARBINARY)", "null")
.addExpectedValues("ABC", null)
.build());

// TODO BUG: airbyte returns binary representation instead of readable one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import io.airbyte.commons.json.Jsons;
import io.airbyte.commons.util.AutoCloseableIterator;
import io.airbyte.db.jdbc.JdbcDatabase;
import io.airbyte.db.jdbc.JdbcSourceOperations;
import io.airbyte.integrations.base.IntegrationRunner;
import io.airbyte.integrations.base.Source;
import io.airbyte.integrations.base.ssh.SshWrappedSource;
Expand Down Expand Up @@ -254,9 +253,4 @@ public enum ReplicationMethod {
CDC
}

@Override
protected JdbcSourceOperations getSourceOperations() {
return new MySqlSourceOperations();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.ImmutableMap;
import io.airbyte.commons.json.Jsons;
import io.airbyte.db.jdbc.JdbcSourceOperations;
import io.airbyte.integrations.base.IntegrationRunner;
import io.airbyte.integrations.base.Source;
import io.airbyte.integrations.source.jdbc.AbstractJdbcSource;
Expand Down Expand Up @@ -53,9 +52,4 @@ public Set<String> getExcludedInternalNameSpaces() {
"INFORMATION_SCHEMA");
}

@Override
protected JdbcSourceOperations getSourceOperations() {
return new SnowflakeSourceOperations();
}

}
1 change: 1 addition & 0 deletions docs/integrations/sources/mssql.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,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.3.9 | 2021-11-09 | [7386](https://github.com/airbytehq/airbyte/pull/7386) | Improve support for binary and varbinary data types | |
| 0.3.8 | 2021-10-26 | [7386](https://github.com/airbytehq/airbyte/pull/7386) | Fixed data type (smalldatetime, smallmoney) conversion from mssql source | |
| 0.3.7 | 2021-09-30 | [6585](https://github.com/airbytehq/airbyte/pull/6585) | Improved SSH Tunnel key generation steps | |
| 0.3.6 | 2021-09-17 | [6318](https://github.com/airbytehq/airbyte/pull/6318) | Added option to connect to DB via SSH | |
Expand Down

0 comments on commit 70ed18b

Please sign in to comment.