Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destinatino S3 Data Lake: parallelize data cleaner; handle failure case #52123

Merged
merged 2 commits into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import io.airbyte.cdk.load.test.util.IntegrationTest.Companion.isNamespaceOld
import io.airbyte.cdk.load.test.util.IntegrationTest.Companion.randomizedNamespaceRegex
import io.airbyte.integrations.destination.s3_data_lake.io.S3DataLakeTableCleaner
import io.airbyte.integrations.destination.s3_data_lake.io.S3DataLakeUtil
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import org.apache.iceberg.catalog.Catalog
import org.apache.iceberg.catalog.Namespace
import org.apache.iceberg.catalog.SupportsNamespaces
Expand All @@ -24,12 +27,23 @@ class S3DataLakeDestinationCleaner(private val catalog: Catalog) : DestinationCl
// we're passing explicit TableIdentifier to clearTable, so just use SimpleTableIdGenerator
val tableCleaner = S3DataLakeTableCleaner(S3DataLakeUtil(SimpleTableIdGenerator()))

namespaces.forEach { namespace ->
catalog.listTables(namespace).forEach { tableId ->
val table = catalog.loadTable(tableId)
tableCleaner.clearTable(catalog, tableId, table.io(), table.location())
runBlocking(Dispatchers.IO) {
namespaces.forEach { namespace ->
launch {
catalog.listTables(namespace).forEach { tableId ->
try {
val table = catalog.loadTable(tableId)
tableCleaner.clearTable(catalog, tableId, table.io(), table.location())
} catch (e: Exception) {
// catalog.loadTable will fail if the table has no files.
// In this case, we can just hard drop the table, because we know it has
// no corresponding files.
catalog.dropTable(tableId)
}
}
catalog.dropNamespace(namespace)
}
}
catalog.dropNamespace(namespace)
}
}
}
Loading