Skip to content

Commit

Permalink
convert #36466 to kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-airbyte committed Mar 27, 2024
1 parent 0f658ff commit 5cc9873
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import java.time.Instant
import java.time.OffsetDateTime
import java.time.temporal.ChronoUnit
import java.util.*
import java.util.HashMap
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletionStage
import java.util.function.Predicate
Expand Down Expand Up @@ -254,12 +255,18 @@ abstract class JdbcDestinationHandler<DestinationState>(
// This is to handle any destinations that upcase the column names.
// For example - Snowflake with QUOTED_IDENTIFIERS_IGNORE_CASE=TRUE.
val record = recordJson as ObjectNode
record.fieldNames().forEachRemaining { fieldName: String ->
record.set<JsonNode>(
fieldName.lowercase(Locale.getDefault()),
record[fieldName]
)
val newFields: HashMap<String, JsonNode> = HashMap()

val it = record.fieldNames()
while (it.hasNext()) {
val fieldName = it.next()
// We can't directly call record.set here, because that will raise a
// ConcurrentModificationException on the fieldnames iterator.
// Instead, build up a map of new fields and set them all at once.
newFields.put(fieldName.lowercase(Locale.getDefault()), record[fieldName])
}

record.setAll<JsonNode>(newFields)
}
.collect(
toMap(
Expand Down

0 comments on commit 5cc9873

Please sign in to comment.