Skip to content
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

🐛Destination-mysql: fixed normalization tests after changes in python part #15362

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class AdvancedTestDataComparator implements TestDataComparator {

public static final String AIRBYTE_DATE_FORMAT = "yyyy-MM-dd";
public static final String AIRBYTE_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
public static final String AIRBYTE_DATETIME_PARSED_FORMAT = "yyyy-MM-dd HH:mm:ss.S";
public static final String AIRBYTE_DATETIME_WITH_TZ_FORMAT = "yyyy-MM-dd'T'HH:mm:ssXXX";

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import io.airbyte.integrations.destination.ExtendedNameTransformer;
import io.airbyte.integrations.standardtest.destination.comparator.AdvancedTestDataComparator;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -30,7 +32,36 @@ protected boolean compareBooleanValues(String firstBooleanValue, String secondBo
if (secondBooleanValue.equalsIgnoreCase("true") || secondBooleanValue.equalsIgnoreCase("false")) {
return super.compareBooleanValues(firstBooleanValue, secondBooleanValue);
} else {
return super.compareBooleanValues(firstBooleanValue, String.valueOf(secondBooleanValue.equals("1")));
return super.compareBooleanValues(firstBooleanValue,
String.valueOf(secondBooleanValue.equals("1")));
}
}

@Override
protected boolean compareDateTimeValues(String expectedValue, String actualValue) {
var destinationDate = parseLocalDateTime(actualValue);
var expectedDate = LocalDate.parse(expectedValue,
DateTimeFormatter.ofPattern(AIRBYTE_DATETIME_FORMAT));
return expectedDate.equals(destinationDate);
}


private LocalDate parseLocalDateTime(String dateTimeValue) {
if (dateTimeValue != null) {
return LocalDate.parse(dateTimeValue,
DateTimeFormatter.ofPattern(getFormat(dateTimeValue)));
} else {
return null;
}
}

private String getFormat(String dateTimeValue) {
if (dateTimeValue.contains("T")) {
// MySql stores array of objects as a jsonb type, i.e. array of string for all cases
return AIRBYTE_DATETIME_FORMAT;
} else {
// MySql stores datetime as datetime type after normalization
return AIRBYTE_DATETIME_PARSED_FORMAT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class PostgresTestDataComparator extends AdvancedTestDataComparator {

private final ExtendedNameTransformer namingResolver = new ExtendedNameTransformer();

private static final String AIRBYTE_DATETIME_PARSED_FORMAT = "yyyy-MM-dd HH:mm:ss.S";
private static final String POSTGRES_DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";
private static final String POSTGRES_DATETIME_WITH_TZ_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'";

Expand Down