Skip to content

Commit

Permalink
[source-mysql] fix for legacy datetime (#48517)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohansong authored Nov 15, 2024
1 parent 53cf410 commit 33cecdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-mysql/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data:
connectorSubtype: database
connectorType: source
definitionId: 435bb9a5-7887-4809-aa58-28c27df0d7ad
dockerImageTag: 3.9.0-rc.10
dockerImageTag: 3.9.0-rc.11
dockerRepository: airbyte/source-mysql
documentationUrl: https://docs.airbyte.com/integrations/sources/mysql
githubIssueLabel: source-mysql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.airbyte.cdk.ConfigErrorException
import io.airbyte.cdk.StreamIdentifier
import io.airbyte.cdk.command.OpaqueStateValue
import io.airbyte.cdk.data.LeafAirbyteSchemaType
import io.airbyte.cdk.data.LocalDateTimeCodec
import io.airbyte.cdk.data.LocalDateTimeCodec.formatter
import io.airbyte.cdk.data.OffsetDateTimeCodec
import io.airbyte.cdk.discover.Field
Expand Down Expand Up @@ -305,6 +306,20 @@ class MysqlJdbcPartitionFactory(
val ba = Base64.getDecoder().decode(stateValue!!)
Jsons.valueToTree<BinaryNode>(ba)
}
LeafAirbyteSchemaType.TIMESTAMP_WITHOUT_TIMEZONE -> {
val timestampInStatePattern = "yyyy-MM-dd'T'HH:mm:ss"
try {
val formatter: DateTimeFormatter =
DateTimeFormatter.ofPattern(timestampInStatePattern)
Jsons.textNode(
LocalDateTime.parse(stateValue, formatter)
.format(LocalDateTimeCodec.formatter)
)
} catch (e: DateTimeParseException) {
// Resolve to use the new format.
Jsons.valueToTree(stateValue)
}
}
LeafAirbyteSchemaType.TIMESTAMP_WITH_TIMEZONE -> {
val timestampInStatePattern = "yyyy-MM-dd'T'HH:mm:ss"
try {
Expand Down

0 comments on commit 33cecdd

Please sign in to comment.