-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
5 changed files
with
135 additions
and
31 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
36 changes: 36 additions & 0 deletions
36
...tion/kotlin/io/airbyte/integrations/destination/iceberg/v2/IcebergExpectedRecordMapper.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,36 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.iceberg.v2 | ||
|
||
import io.airbyte.cdk.load.data.AirbyteType | ||
import io.airbyte.cdk.load.data.AirbyteValue | ||
import io.airbyte.cdk.load.data.ArrayValue | ||
import io.airbyte.cdk.load.data.ObjectValue | ||
import io.airbyte.cdk.load.data.TimeWithTimezoneValue | ||
import io.airbyte.cdk.load.data.TimeWithoutTimezoneValue | ||
import io.airbyte.cdk.load.test.util.ExpectedRecordMapper | ||
import io.airbyte.cdk.load.test.util.OutputRecord | ||
|
||
/** | ||
* Iceberg doesn't have a TimeWithTimezone type. So map expectedRecords' TimeWithTimezone to | ||
* TimeWithoutTimezone. | ||
*/ | ||
object IcebergExpectedRecordMapper : ExpectedRecordMapper { | ||
override fun mapRecord(expectedRecord: OutputRecord, schema: AirbyteType): OutputRecord { | ||
val mappedData = mapTimeTzToTimeNtz(expectedRecord.data) | ||
return expectedRecord.copy(data = mappedData as ObjectValue) | ||
} | ||
|
||
private fun mapTimeTzToTimeNtz(value: AirbyteValue): AirbyteValue = | ||
when (value) { | ||
is TimeWithTimezoneValue -> TimeWithoutTimezoneValue(value.value.toLocalTime()) | ||
is ArrayValue -> ArrayValue(value.values.map { mapTimeTzToTimeNtz(it) }) | ||
is ObjectValue -> | ||
ObjectValue( | ||
value.values.mapValuesTo(linkedMapOf()) { (_, v) -> mapTimeTzToTimeNtz(v) } | ||
) | ||
else -> value | ||
} | ||
} |
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