-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
51 changed files
with
478 additions
and
46 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
33 changes: 33 additions & 0 deletions
33
...ain/kotlin/io/airbyte/integrations/destination/mysql/typing_deduping/MysqlSqlGenerator.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,33 @@ | ||
package io.airbyte.integrations.destination.mysql.typing_deduping | ||
|
||
import io.airbyte.cdk.integrations.destination.jdbc.typing_deduping.RawOnlySqlGenerator | ||
import io.airbyte.integrations.base.destination.typing_deduping.StreamId | ||
import io.airbyte.integrations.base.destination.typing_deduping.StreamId.Companion.concatenateRawTableName | ||
import io.airbyte.integrations.destination.mysql.MySQLNameTransformer | ||
|
||
class MysqlSqlGenerator : RawOnlySqlGenerator(MySQLNameTransformer()) { | ||
|
||
override fun buildStreamId( | ||
namespace: String, | ||
name: String, | ||
rawNamespaceOverride: String | ||
): StreamId { | ||
return StreamId( | ||
namingTransformer.getNamespace(namespace), | ||
namingTransformer.convertStreamName(name), | ||
namingTransformer.getNamespace(rawNamespaceOverride), | ||
// The default implementation is just convertStreamName(concatenate()). | ||
// Wrap in getIdentifier to also truncate. | ||
// This is probably only necessary because the mysql name transformer | ||
// doesn't call convertStreamName in getIdentifier (probably a bug?). | ||
// But that entire NameTransformer interface is a hot mess anyway. | ||
namingTransformer.getIdentifier( | ||
namingTransformer.convertStreamName( | ||
concatenateRawTableName(namespace, name), | ||
), | ||
), | ||
namespace, | ||
name, | ||
) | ||
} | ||
} |
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) | ||
} | ||
} | ||
} |
Oops, something went wrong.