-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pubsub, Pulsar, Redis, Redshift, Rocket destinations : Enable DAT tes…
…ts (#12143) * enable DAT tests for Pulsar * Enable DAT test for pubsub, redis, redshift, rocket * format * fix normalized data fetch * cover "other" result type for arrays * remove deserialization because now we have already parsed node * fix bugspot * fix unicode case
- Loading branch information
1 parent
31485d7
commit aab1533
Showing
7 changed files
with
200 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...gration/java/io/airbyte/integrations/destination/redshift/RedshiftTestDataComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.redshift; | ||
|
||
import io.airbyte.integrations.standardtest.destination.comparator.AdvancedTestDataComparator; | ||
import java.time.DateTimeException; | ||
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; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class RedshiftTestDataComparator extends AdvancedTestDataComparator { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(RedshiftTestDataComparator.class); | ||
|
||
private final RedshiftSQLNameTransformer namingResolver = new RedshiftSQLNameTransformer(); | ||
|
||
protected static final String REDSHIFT_DATETIME_WITH_TZ_FORMAT = "yyyy-MM-dd HH:mm:ssX"; | ||
|
||
@Override | ||
protected ZonedDateTime parseDestinationDateWithTz(String destinationValue) { | ||
return ZonedDateTime.parse(destinationValue, DateTimeFormatter.ofPattern(REDSHIFT_DATETIME_WITH_TZ_FORMAT)).withZoneSameInstant(ZoneOffset.UTC); | ||
} | ||
|
||
@Override | ||
protected boolean compareDateTimeValues(String airbyteMessageValue, String destinationValue) { | ||
try { | ||
var format = DateTimeFormatter.ofPattern(AIRBYTE_DATETIME_FORMAT); | ||
LocalDateTime dateTime = LocalDateTime.parse(destinationValue, DateTimeFormatter.ofPattern(REDSHIFT_DATETIME_WITH_TZ_FORMAT)); | ||
return super.compareDateTimeValues(airbyteMessageValue, format.format(dateTime)); | ||
} catch (DateTimeException e) { | ||
LOGGER.warn("Fail to convert values to DateTime. Try to compare as text. Airbyte value({}), Destination value ({}). Exception: {}", | ||
airbyteMessageValue, destinationValue, e); | ||
return compareTextValues(airbyteMessageValue, destinationValue); | ||
} | ||
} | ||
|
||
@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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters