Skip to content

Commit e687227

Browse files
authored
CH: Properly scale decimals before validating size. (#69154)
1 parent c761e11 commit e687227

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

airbyte-integrations/connectors/destination-clickhouse/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ data:
22
connectorSubtype: database
33
connectorType: destination
44
definitionId: ce0d828e-1dc4-496c-b122-2da42e637e48
5-
dockerImageTag: 2.1.9
5+
dockerImageTag: 2.1.10
66
dockerRepository: airbyte/destination-clickhouse
77
githubIssueLabel: destination-clickhouse
88
icon: clickhouse.svg

airbyte-integrations/connectors/destination-clickhouse/src/main/kotlin/io/airbyte/integrations/destination/clickhouse/write/transform/ClickhouseCoercer.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,14 @@ class ClickhouseCoercer : ValueCoercer {
117117
val INT64_MIN = BigInteger(Long.MIN_VALUE.toString())
118118

119119
// below are copied from "deprecated" but still actively used
120-
// com.clickhouse.data.format.BinaryStreamUtils.DECIMAL64_MAX
120+
// com.clickhouse.data.format.BinaryStreamUtils
121121
// we can't directly use them because the deprecated status causes a
122122
// compiler warning which we don't tolerate in CI :smithers:
123-
val DECIMAL128_MAX = BigDecimal("100000000000000000000000000000000000000")
124-
val DECIMAL128_MIN = BigDecimal("-100000000000000000000000000000000000000")
123+
//
124+
// Further scale the CH defined limits by -9 (our defined scale for decimals) to mimic their
125+
// scaling without the overhead (they multiply every value by the scale before comparison).
126+
val DECIMAL128_MAX = BigDecimal("100000000000000000000000000000")
127+
val DECIMAL128_MIN = BigDecimal("-100000000000000000000000000000")
125128

126129
// used by both date 32 and date time 64
127130
val DATE32_MAX_RAW = LocalDate.of(2299, 12, 31)

airbyte-integrations/connectors/destination-clickhouse/src/test/kotlin/io/airbyte/integrations/destination/clickhouse/write/transform/ClickhouseCoercerTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ import java.time.LocalDateTime
4141
import java.time.LocalTime
4242
import java.time.OffsetTime
4343
import java.time.ZoneOffset
44-
import kotlin.test.Test
4544
import kotlin.test.assertEquals
45+
import org.junit.jupiter.api.Test
4646
import org.junit.jupiter.api.extension.ExtendWith
4747
import org.junit.jupiter.params.ParameterizedTest
4848
import org.junit.jupiter.params.provider.Arguments
@@ -250,6 +250,7 @@ class ClickhouseCoercerTest {
250250
Arguments.of("100000000000000000000000000000000000001"),
251251
Arguments.of("999999999999999999999999999999999999999.9"),
252252
Arguments.of("-999999999999999999999999999999999999999.12"),
253+
Arguments.of("3.4028234663852886E+37"),
253254
)
254255

255256
@JvmStatic

docs/integrations/destinations/clickhouse.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ You can also use a pre-existing user but we highly recommend creating a dedicate
104104

105105
| Version | Date | Pull Request | Subject |
106106
|:-----------|:-----------|:-----------------------------------------------------------|:-------------------------------------------------------------------------------|
107+
| 2.1.10 | 2025-11-03 | [69154](https://github.com/airbytehq/airbyte/pull/69154) | Fix decimal validation |
107108
| 2.1.9 | 2025-10-30 | [69100](https://github.com/airbytehq/airbyte/pull/69100) | Upgrade to CDK 0.1.61 to fix state index bug |
108109
| 2.1.8 | 2025-10-28 | [68186](https://github.com/airbytehq/airbyte/pull/68186) | Upgrade to CDK 0.1.59 |
109110
| 2.1.7 | 2025-10-21 | [67153](https://github.com/airbytehq/airbyte/pull/67153) | Implement new proto schema implementation |

0 commit comments

Comments
 (0)