File tree 2 files changed +12
-7
lines changed
airbyte-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/load/message
airbyte-integrations/connectors/destination-s3-data-lake/src/main/kotlin/io/airbyte/integrations/destination/s3_data_lake
2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -183,8 +183,8 @@ data class EnrichedDestinationRecordAirbyteValue(
183
183
184
184
data class DestinationRecordRaw (
185
185
val stream : DestinationStream .Descriptor ,
186
- private val rawData : AirbyteMessage ,
187
- private val serialized : String
186
+ val rawData : AirbyteMessage ,
187
+ val serialized : String
188
188
) {
189
189
fun asDestinationRecordAirbyteValue (): DestinationRecordAirbyteValue {
190
190
return DestinationRecordAirbyteValue (
Original file line number Diff line number Diff line change 4
4
5
5
package io.airbyte.integrations.destination.s3_data_lake
6
6
7
+ import com.fasterxml.jackson.databind.JsonNode
7
8
import io.airbyte.cdk.load.command.Dedupe
8
9
import io.airbyte.cdk.load.command.DestinationCatalog
9
10
import io.airbyte.cdk.load.data.ObjectValue
11
+ import io.airbyte.cdk.load.data.json.toAirbyteValue
10
12
import io.airbyte.cdk.load.message.DestinationRecordAirbyteValue
11
13
import io.airbyte.cdk.load.message.DestinationRecordRaw
12
14
import io.airbyte.cdk.load.pipeline.InputPartitioner
@@ -27,15 +29,18 @@ class S3DataLakePartitioner(catalog: DestinationCatalog) : InputPartitioner {
27
29
private val random = Random (System .currentTimeMillis())
28
30
29
31
override fun getPartition (record : DestinationRecordRaw , numParts : Int ): Int {
30
- val recordAirbyteValue = record.asDestinationRecordAirbyteValue()
31
-
32
32
if (numParts == 1 ) {
33
33
return 0
34
34
}
35
35
36
- streamToPrimaryKeyFieldNames[recordAirbyteValue.stream]?.let { primaryKey ->
37
- val primaryKeyValues =
38
- primaryKey.map { it.map { key -> (recordAirbyteValue.data as ObjectValue ).values[key] } }
36
+ streamToPrimaryKeyFieldNames[record.stream]?.let { primaryKey ->
37
+ val jsonData = record.rawData.record.data as JsonNode
38
+
39
+ val primaryKeyValues = primaryKey.map { keys ->
40
+ keys.map { key ->
41
+ if (jsonData.has(key)) jsonData.get(key) else null
42
+ }
43
+ }
39
44
val hash = primaryKeyValues.hashCode()
40
45
/* * abs(MIN_VALUE) == MIN_VALUE, so we need to handle this case separately */
41
46
if (hash == Int .MIN_VALUE ) {
You can’t perform that action at this time.
0 commit comments