-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
82 additions
and
76 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
58 changes: 58 additions & 0 deletions
58
airbyte-cdk/bulk/core/load/src/testFixtures/kotlin/io/airbyte/cdk/test/util/OutputRecord.kt
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,58 @@ | ||
package io.airbyte.cdk.test.util | ||
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import java.time.Instant | ||
import java.util.UUID | ||
|
||
/** A record that we expect to exist in the destination, whether raw _or_ final. */ | ||
data class OutputRecord( | ||
val rawId: UUID?, | ||
val extractedAt: Instant, | ||
val loadedAt: Instant?, | ||
val generationId: Long?, | ||
/** | ||
* strongly-typed map, e.g. ZonedDateTime for timestamp_with_timezone. this makes destination | ||
* test implementations easier. values can be null, b/c warehouse destinations with a JSON | ||
* column type can be either SQL null, or JSON null, and we want to distinguish between those. | ||
* Destinations _must_ filter out the airbyte_* fields from this map. | ||
*/ | ||
val data: Map<String, Any?>, | ||
val airbyteMeta: JsonNode?, | ||
) { | ||
/** Utility constructor with easier types to write by hand */ | ||
constructor( | ||
rawId: String, | ||
extractedAt: Long, | ||
loadedAt: Long?, | ||
generationId: Long?, | ||
data: Map<String, Any?>, | ||
airbyteMeta: String?, | ||
) : this( | ||
UUID.fromString(rawId), | ||
Instant.ofEpochMilli(extractedAt), | ||
loadedAt?.let { Instant.ofEpochMilli(it) }, | ||
generationId, | ||
data, | ||
airbyteMeta?.let { ObjectMapper().readTree(it) }, | ||
) | ||
|
||
/** | ||
* Utility constructor for "expected records". [rawId] and [loadedAt] are generated by the | ||
* destination at runtime, so we don't have those when writing the test. Just generate arbitrary | ||
* values for them. | ||
*/ | ||
constructor( | ||
extractedAt: Long, | ||
generationId: Long?, | ||
data: Map<String, Any?>, | ||
airbyteMeta: String?, | ||
) : this( | ||
null, | ||
Instant.ofEpochMilli(extractedAt), | ||
loadedAt = null, | ||
generationId, | ||
data, | ||
airbyteMeta?.let { ObjectMapper().readTree(it) }, | ||
) | ||
} |
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