-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into daryna/source-bing-ads/stream-budget-and-p…
…roduct_dimension_performance_report
- Loading branch information
Showing
300 changed files
with
5,208 additions
and
3,430 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
airbyte-cdk/java/airbyte-cdk/core/src/main/resources/version.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.23.6 | ||
version=0.23.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 68 additions & 11 deletions
79
...rc/main/java/io/airbyte/integrations/base/destination/typing_deduping/TyperDeduperUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,72 @@ | ||
package io.airbyte.integrations.base.destination.typing_deduping | ||
|
||
import com.google.common.collect.Streams | ||
import io.airbyte.cdk.integrations.util.ConnectorExceptionUtil.getResultsOrLogAndThrowFirst | ||
import io.airbyte.commons.concurrency.CompletableFutures | ||
import java.util.* | ||
import java.util.concurrent.CompletableFuture | ||
import java.util.concurrent.CompletionStage | ||
import java.util.concurrent.ExecutorService | ||
|
||
/** | ||
* Extracts all the "raw" and "final" schemas identified in the [parsedCatalog] and ensures they | ||
* exist in the Destination Database. | ||
*/ | ||
fun prepareAllSchemas(parsedCatalog: ParsedCatalog, sqlGenerator: SqlGenerator, destinationHandler: DestinationHandler) { | ||
val rawSchema = parsedCatalog.streams.mapNotNull { it.id.rawNamespace } | ||
val finalSchema = parsedCatalog.streams.mapNotNull { it.id.finalNamespace } | ||
val createAllSchemasSql = rawSchema.union(finalSchema) | ||
.map { sqlGenerator.createSchema(it) } | ||
.toList() | ||
destinationHandler.execute(Sql.concat(createAllSchemasSql)) | ||
|
||
class TyperDeduperUtil { | ||
companion object { | ||
|
||
@JvmStatic | ||
fun executeRawTableMigrations( | ||
executorService: ExecutorService, | ||
sqlGenerator: SqlGenerator, | ||
destinationHandler: DestinationHandler, | ||
v1V2Migrator: DestinationV1V2Migrator, | ||
v2TableMigrator: V2TableMigrator, | ||
parsedCatalog: ParsedCatalog | ||
) { | ||
// TODO: Either the migrations run the soft reset and create v2 tables or the actual prepare tables. | ||
// unify the logic | ||
// with current state of raw tables & final tables. This is done first before gather initial state | ||
// to avoid recreating | ||
// final tables later again. | ||
val runMigrationsResult = | ||
CompletableFutures.allOf(parsedCatalog.streams().stream() | ||
.map { streamConfig -> runMigrationsAsync(executorService, sqlGenerator, destinationHandler, v1V2Migrator, v2TableMigrator, streamConfig) } | ||
.toList()).toCompletableFuture().join() | ||
getResultsOrLogAndThrowFirst("The following exceptions were thrown attempting to run migrations:\n", runMigrationsResult) | ||
} | ||
|
||
/** | ||
* Extracts all the "raw" and "final" schemas identified in the [parsedCatalog] and ensures they | ||
* exist in the Destination Database. | ||
*/ | ||
@JvmStatic | ||
fun prepareSchemas( | ||
sqlGenerator: SqlGenerator, | ||
destinationHandler: DestinationHandler, | ||
parsedCatalog: ParsedCatalog) { | ||
val rawSchema = parsedCatalog.streams.stream().map { it.id.rawNamespace } | ||
val finalSchema = parsedCatalog.streams.stream().map { it.id.finalNamespace } | ||
val createAllSchemasSql = Streams.concat<String>(rawSchema, finalSchema) | ||
.filter(Objects::nonNull) | ||
.distinct() | ||
.map(sqlGenerator::createSchema) | ||
.toList() | ||
destinationHandler.execute(Sql.concat(createAllSchemasSql)) | ||
} | ||
|
||
private fun runMigrationsAsync( | ||
executorService: ExecutorService, | ||
sqlGenerator: SqlGenerator, | ||
destinationHandler: DestinationHandler, | ||
v1V2Migrator: DestinationV1V2Migrator, | ||
v2TableMigrator: V2TableMigrator, | ||
streamConfig: StreamConfig): CompletionStage<Void> { | ||
return CompletableFuture.runAsync({ | ||
try { | ||
v1V2Migrator.migrateIfNecessary(sqlGenerator, destinationHandler, streamConfig) | ||
v2TableMigrator.migrateIfNecessary(streamConfig) | ||
} catch (e: java.lang.Exception) { | ||
throw RuntimeException(e) | ||
} | ||
}, executorService) | ||
} | ||
} | ||
} |
Oops, something went wrong.