Skip to content

Commit

Permalink
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/fas…
Browse files Browse the repository at this point in the history
…ter-file-4
  • Loading branch information
benmoriceau committed Dec 19, 2024
2 parents 0ca95e2 + 044ba4b commit 70d3c49
Show file tree
Hide file tree
Showing 46 changed files with 1,239 additions and 1,870 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class MockBasicFunctionalityIntegrationTest :
super.testAppendSchemaEvolution()
}

@Disabled("flaky")
@Test
override fun testDedup() {
super.testDedup()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ object MockDestinationBackend {
getFile(filename).addAll(records)
}

@Synchronized
fun upsert(
filename: String,
primaryKey: List<List<String>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2024 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.cdk.load.data.iceberg.parquet
package io.airbyte.cdk.load.util

import io.airbyte.cdk.load.data.TimeStringToInteger
import java.time.LocalDate
Expand All @@ -13,12 +13,17 @@ import java.time.OffsetTime
import java.time.ZoneOffset
import java.time.ZonedDateTime

/** Collection of time/date string to time/date object conversion utilities. */
object TimeStringUtility {

fun toLocalDate(dateString: String): LocalDate {
return LocalDate.parse(dateString, TimeStringToInteger.DATE_TIME_FORMATTER)
}

fun toLocalDateTime(dateString: String): LocalDateTime {
return LocalDateTime.parse(dateString, TimeStringToInteger.DATE_TIME_FORMATTER)
}

fun toOffset(timeString: String): LocalTime {
return try {
toMicrosOfDayWithTimezone(timeString)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright (c) 2024 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.cdk.load.util

import io.airbyte.cdk.load.data.TimeStringToInteger
import java.time.LocalDate
import java.time.LocalDateTime
import java.time.LocalTime
import java.time.OffsetTime
import java.time.ZoneOffset
import java.time.ZonedDateTime
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertThrows
import org.junit.jupiter.api.Test

internal class TimeStringUtilityTest {

@Test
fun testToLocalDate() {
val localDateString = "2024-11-18"
val localDate = TimeStringUtility.toLocalDate(localDateString)
assertEquals(
LocalDate.parse(localDateString, TimeStringToInteger.DATE_TIME_FORMATTER),
localDate
)
}

@Test
fun testToLocalDateInvalidDateString() {
val invalidDateStr = "invalid-date"
assertThrows(java.time.format.DateTimeParseException::class.java) {
TimeStringUtility.toLocalDate(invalidDateStr)
}
}

@Test
fun testToLocalDateTime() {
val localDateTimeString = "2024-11-18T12:34:56Z"
val localDateTime = TimeStringUtility.toLocalDateTime(localDateTimeString)
assertEquals(
LocalDateTime.parse(localDateTimeString, TimeStringToInteger.DATE_TIME_FORMATTER),
localDateTime
)
}

@Test
fun testToOffsetWithTimezone() {
val offsetWithTimezoneString = "12:34:56Z"
val offsetWithTimezone = TimeStringUtility.toOffset(offsetWithTimezoneString)
assertEquals(
OffsetTime.parse(offsetWithTimezoneString, TimeStringToInteger.TIME_FORMATTER)
.toLocalTime(),
offsetWithTimezone
)
}

@Test
fun testToOffsetWithoutTimezone() {
val offsetWithoutTimezoneString = "12:34:56"
val offsetWithoutTimezone = TimeStringUtility.toOffset(offsetWithoutTimezoneString)
assertEquals(
LocalTime.parse(offsetWithoutTimezoneString, TimeStringToInteger.TIME_FORMATTER),
offsetWithoutTimezone
)
}

@Test
fun testToOffsetDateTimeWithTimezone() {
val offsetWithTimezoneString = "2024-11-18T12:34:56Z"
val offsetWithTimezone = TimeStringUtility.toOffsetDateTime(offsetWithTimezoneString)
assertEquals(
ZonedDateTime.parse(offsetWithTimezoneString, TimeStringToInteger.DATE_TIME_FORMATTER)
.toOffsetDateTime(),
offsetWithTimezone
)
}

@Test
fun testToOffsetDateTimeWithoutTimezone() {
val offsetWithoutTimezoneString = "2024-11-18T12:34:56"
val offsetWithoutTimezone = TimeStringUtility.toOffsetDateTime(offsetWithoutTimezoneString)
assertEquals(
LocalDateTime.parse(
offsetWithoutTimezoneString,
TimeStringToInteger.DATE_TIME_FORMATTER
)
.atOffset(ZoneOffset.UTC),
offsetWithoutTimezone
)
}

@Test
fun testToOffsetDateTimeInvalidFormat() {
val invalidDateTime = "invalid-datetime"
assertThrows(java.time.format.DateTimeParseException::class.java) {
TimeStringUtility.toOffsetDateTime(invalidDateTime)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import io.airbyte.cdk.load.data.StringValue
import io.airbyte.cdk.load.data.TimeValue
import io.airbyte.cdk.load.data.TimestampValue
import io.airbyte.cdk.load.data.UnknownValue
import io.airbyte.cdk.load.util.TimeStringUtility
import org.apache.iceberg.Schema
import org.apache.iceberg.data.GenericRecord
import org.apache.iceberg.types.Type
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import semver
import yaml

from metadata_service.docker_hub import get_latest_version_on_dockerhub
from metadata_service.models.generated.ConnectorMetadataDefinitionV0 import ConnectorMetadataDefinitionV0
from metadata_service.validators import metadata_validator

Expand Down Expand Up @@ -133,7 +134,8 @@ def test_validation_pass_on_docker_image_tag_increment(metadata_definition, incr
assert error_message is None


def test_validation_pass_on_same_docker_image_tag(metadata_definition):
def test_validation_pass_on_same_docker_image_tag(mocker, metadata_definition):
mocker.patch.object(metadata_validator, "get_latest_version_on_dockerhub", return_value=metadata_definition.data.dockerImageTag)
success, error_message = metadata_validator.validate_docker_image_tag_is_not_decremented(metadata_definition, None)
assert success
assert error_message is None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data:
connectorSubtype: api
connectorType: source
definitionId: 80a54ea2-9959-4040-aac1-eee42423ec9b
dockerImageTag: 2.1.5
dockerImageTag: 2.1.6
releases:
breakingChanges:
2.0.0:
Expand Down
Loading

0 comments on commit 70d3c49

Please sign in to comment.