-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
10 changed files
with
152 additions
and
44 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
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
24 changes: 24 additions & 0 deletions
24
...integration/kotlin/io/airbyte/integrations/destination/mysql/MysqlTestSourceOperations.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,24 @@ | ||
package io.airbyte.integrations.destination.mysql | ||
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.fasterxml.jackson.databind.node.ObjectNode | ||
import io.airbyte.cdk.db.jdbc.JdbcSourceOperations | ||
import io.airbyte.commons.json.Jsons | ||
import java.sql.ResultSet | ||
import java.sql.SQLException | ||
import java.util.Locale | ||
|
||
class MysqlTestSourceOperations : JdbcSourceOperations() { | ||
@Throws(SQLException::class) | ||
override fun copyToJsonField(resultSet: ResultSet, colIndex: Int, json: ObjectNode) { | ||
val columnName = resultSet.metaData.getColumnName(colIndex) | ||
val columnTypeName = resultSet.metaData.getColumnTypeName(colIndex).lowercase(Locale.getDefault()) | ||
|
||
// JSON has no equivalent in JDBCType | ||
if ("json" == columnTypeName) { | ||
json.set<JsonNode>(columnName, Jsons.deserializeExact(resultSet.getString(colIndex))) | ||
} else { | ||
super.copyToJsonField(resultSet, colIndex, json) | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...airbyte/integrations/destination/mysql/typing_deduping/AbstractMysqlTypingDedupingTest.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,54 @@ | ||
package io.airbyte.integrations.destination.mysql.typing_deduping; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.fasterxml.jackson.databind.node.ObjectNode | ||
import io.airbyte.cdk.integrations.destination.jdbc.typing_deduping.RawOnlySqlGenerator | ||
import io.airbyte.cdk.integrations.standardtest.destination.typing_deduping.JdbcTypingDedupingTest | ||
import io.airbyte.integrations.base.destination.typing_deduping.SqlGenerator | ||
import io.airbyte.integrations.destination.mysql.MySQLDestination | ||
import io.airbyte.integrations.destination.mysql.MySQLDestinationAcceptanceTest | ||
import io.airbyte.integrations.destination.mysql.MySQLNameTransformer | ||
import io.airbyte.integrations.destination.mysql.MysqlTestSourceOperations | ||
import javax.sql.DataSource | ||
import org.junit.jupiter.api.AfterAll | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.testcontainers.containers.MySQLContainer | ||
|
||
abstract class AbstractMysqlTypingDedupingTest( | ||
override val imageName: String = "airbyte/destination-mysql:dev", | ||
override val sqlGenerator: SqlGenerator = RawOnlySqlGenerator(MySQLNameTransformer()), | ||
override val sourceOperations: MysqlTestSourceOperations = MysqlTestSourceOperations(), | ||
override val baseConfig: ObjectNode = Companion.config, | ||
) : JdbcTypingDedupingTest() { | ||
|
||
override fun getDataSource(config: JsonNode?): DataSource = | ||
MySQLDestination().getDataSource(baseConfig) | ||
|
||
override fun disableFinalTableComparison(): Boolean { | ||
// TODO delete this in the next stacked PR | ||
return true | ||
} | ||
|
||
companion object { | ||
private lateinit var testContainer: MySQLContainer<*> | ||
private lateinit var config: ObjectNode | ||
|
||
@JvmStatic | ||
@BeforeAll | ||
@Throws(Exception::class) | ||
fun setupMysql() { | ||
testContainer = MySQLContainer("mysql:8.0") | ||
testContainer.start() | ||
MySQLDestinationAcceptanceTest.configureTestContainer(testContainer) | ||
|
||
config = MySQLDestinationAcceptanceTest.getConfigFromTestContainer(testContainer) | ||
} | ||
|
||
@JvmStatic | ||
@AfterAll | ||
fun teardownMysql() { | ||
testContainer.stop() | ||
testContainer.close() | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...byte/integrations/destination/mysql/typing_deduping/MysqlRawOverrideTypingDedupingTest.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,9 @@ | ||
package io.airbyte.integrations.destination.mysql.typing_deduping | ||
|
||
import com.fasterxml.jackson.databind.node.ObjectNode | ||
|
||
class MysqlRawOverrideTypingDedupingTest : AbstractMysqlTypingDedupingTest() { | ||
|
||
override val baseConfig: ObjectNode = | ||
super.baseConfig.put("raw_table_database", "overridden_raw_dataset") | ||
} |
4 changes: 4 additions & 0 deletions
4
...tlin/io/airbyte/integrations/destination/mysql/typing_deduping/MysqlTypingDedupingTest.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,4 @@ | ||
package io.airbyte.integrations.destination.mysql.typing_deduping | ||
|
||
// Just a concrete instantiation of the abstract class. No overrides needed. | ||
class MysqlTypingDedupingTest: AbstractMysqlTypingDedupingTest() |