-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Mssql destination: enable DAT tests, use nvarchar and datetime2 by default #12305
Changes from 1 commit
26a9a93
c024123
3621ec8
4472750
b517b19
5f668f1
67503fe
06fac71
fafe0d5
86d05a4
b67626a
45da54d
9cac9ed
64ee6eb
0921109
97832b6
bca6d64
155e8a2
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.commons.json.Jsons; | ||
import java.time.ZoneOffset; | ||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
@@ -91,6 +92,8 @@ protected boolean compareJsonNodes(final JsonNode expectedValue, final JsonNode | |
return compareDateValues(expectedValue.asText(), actualValue.asText()); | ||
} else if (expectedValue.isArray() && actualValue.isArray()) { | ||
return compareArrays(expectedValue, actualValue); | ||
} else if (expectedValue.isArray() && isQuotedArray(actualValue)) { | ||
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. this is a specific case of your destination. It should be handled inside your destination implementation. 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. Thanks, will do it. |
||
return compareArrays(expectedValue, Jsons.deserialize(actualValue.asText())); | ||
} else if (expectedValue.isObject() && actualValue.isObject()) { | ||
compareObjects(expectedValue, actualValue); | ||
return true; | ||
|
@@ -99,6 +102,10 @@ protected boolean compareJsonNodes(final JsonNode expectedValue, final JsonNode | |
} | ||
} | ||
|
||
protected boolean isQuotedArray(JsonNode actualValue) { | ||
sashaNeshcheret marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return actualValue.isTextual() && actualValue.asText().matches("^\\[.*\\]$"); | ||
} | ||
|
||
protected boolean compareString(final JsonNode expectedValue, final JsonNode actualValue) { | ||
return expectedValue.asText().equals(actualValue.asText()); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package io.airbyte.integrations.destination.mssql; | ||
|
||
import io.airbyte.integrations.destination.ExtendedNameTransformer; | ||
import io.airbyte.integrations.standardtest.destination.comparator.AdvancedTestDataComparator; | ||
import java.time.LocalDateTime; | ||
import java.time.ZoneOffset; | ||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MSSQLTestDataComparator extends AdvancedTestDataComparator { | ||
|
||
public static final String ACTUAL_MSSQL_AIRBYTE_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss.S"; | ||
private final ExtendedNameTransformer namingResolver = new ExtendedNameTransformer(); | ||
|
||
|
||
@Override | ||
protected boolean compareDateTimeValues(String airbyteMessageValue, String destinationValue) { | ||
if(!isDateTimeValue(destinationValue)){ | ||
destinationValue = LocalDateTime.parse(destinationValue, DateTimeFormatter.ofPattern(ACTUAL_MSSQL_AIRBYTE_DATETIME_FORMAT)).toString(); | ||
} | ||
return super.compareDateTimeValues(airbyteMessageValue, destinationValue); | ||
} | ||
|
||
@Override | ||
protected ZonedDateTime parseDestinationDateWithTz(String destinationValue) { | ||
LocalDateTime parsedDateTime = LocalDateTime.parse(destinationValue, DateTimeFormatter.ofPattern(ACTUAL_MSSQL_AIRBYTE_DATETIME_FORMAT)); | ||
return ZonedDateTime.of(parsedDateTime, ZoneOffset.UTC); | ||
} | ||
|
||
@Override | ||
protected List<String> resolveIdentifier(final String identifier) { | ||
final List<String> result = new ArrayList<>(); | ||
final String resolved = namingResolver.getIdentifier(identifier); | ||
result.add(identifier); | ||
result.add(resolved); | ||
if (!resolved.startsWith("\"")) { | ||
result.add(resolved.toLowerCase()); | ||
result.add(resolved.toUpperCase()); | ||
} | ||
return result; | ||
} | ||
|
||
} |
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.
If I'm not mistaken, this test will effect normalization of all destinations. Are you sure that we are safe to do it?
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.
Yes, you are right. @grubberr will check if it works for all destinations and will make changes in scope of the PR if not.