Skip to content

Commit 0db743d

Browse files
authored
Port mysql divizion by zero fix to the CDK (#66674)
1 parent 348ad28 commit 0db743d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

airbyte-cdk/bulk/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Version 0.1.41
2+
3+
**Extract CDK**
4+
5+
* **Changed:** Prevent a devision by zero error when a table cannot be partitioned.
6+
17
## Version 0.1.40
28

39
Add gradle task to bump CDK version + add changelog entry

airbyte-cdk/bulk/toolkits/extract-jdbc/src/main/kotlin/io/airbyte/cdk/read/JdbcPartitionsCreator.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ class JdbcConcurrentPartitionsCreator<
253253
.filter { random.nextDouble() < secondarySamplingRate }
254254
.mapNotNull { (splitBoundary: OpaqueStateValue?, _) -> splitBoundary }
255255
.distinct()
256+
257+
// Handle edge case with empty split boundaries when sampling rate is too low,
258+
// causing random filtering to discard all sampled boundaries, which would
259+
// lead to division by zero the in the split() function. Fall back to single partition.
260+
if (splitBoundaries.isEmpty()) {
261+
log.warn { "No split boundaries found, using single partition" }
262+
return listOf(JdbcNonResumablePartitionReader(partition))
263+
}
256264
val partitions: List<JdbcPartition<*>> = partitionFactory.split(partition, splitBoundaries)
257265
log.info { "Table will be read by ${partitions.size} concurrent partition reader(s)." }
258266
return partitions.map { JdbcNonResumablePartitionReader(it) }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.1.40
1+
version=0.1.41

0 commit comments

Comments
 (0)