Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-mongodb-v2: remove dependency on airbyte-commons source #34455

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ dependencies {
integrationTestJavaImplementation libs.apache.commons.lang
integrationTestJavaImplementation project(':airbyte-integrations:connectors:source-mongodb-v2')

dataGeneratorImplementation project(':airbyte-cdk:java:airbyte-cdk:airbyte-commons')
dataGeneratorImplementation platform(libs.fasterxml)
dataGeneratorImplementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'

dataGeneratorImplementation project(':airbyte-integrations:connectors:source-mongodb-v2')
dataGeneratorImplementation libs.mongo.driver.sync
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package io.airbyte.integrations.source.mongodb

import com.fasterxml.jackson.core.JsonGenerator
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
import com.github.javafaker.Faker
import io.airbyte.commons.json.Jsons
import io.github.oshai.kotlinlogging.KotlinLogging
import kotlinx.cli.ArgParser
import kotlinx.cli.ArgType
Expand Down Expand Up @@ -31,7 +34,7 @@ object MongoDbInsertClient {
println("Enter password: ")
val password = readln()

var config = mapOf(MongoConstants.DATABASE_CONFIG_CONFIGURATION_KEY to
val config = mapOf(MongoConstants.DATABASE_CONFIG_CONFIGURATION_KEY to
mapOf(
MongoConstants.DATABASE_CONFIGURATION_KEY to databaseName,
MongoConstants.CONNECTION_STRING_CONFIGURATION_KEY to connectionString,
Expand All @@ -42,7 +45,12 @@ object MongoDbInsertClient {

val faker = Faker();

MongoConnectionUtils.createMongoClient(MongoDbSourceConfig(Jsons.deserialize(Jsons.serialize(config)))).use { mongoClient ->
val objectMapper = ObjectMapper().registerModule(JavaTimeModule())
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
objectMapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true)
val roundTrippedConfig = objectMapper.readTree(objectMapper.writeValueAsBytes(config))

MongoConnectionUtils.createMongoClient(MongoDbSourceConfig(roundTrippedConfig)).use { mongoClient ->
val documents = mutableListOf<Document>()
val batches = if (numberOfDocuments > BATCH_SIZE) numberOfDocuments / BATCH_SIZE else 1;
val batchSize = if (numberOfDocuments > BATCH_SIZE) BATCH_SIZE else numberOfDocuments;
Expand Down
Loading