-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
add test that migration output schema same as source schema #3356
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
101 changes: 101 additions & 0 deletions
101
airbyte-migration/src/main/java/io/airbyte/migrate/migrations/MigrationV0_23_0.java
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 |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright (c) 2020 Airbyte | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
package io.airbyte.migrate.migrations; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.migrate.Migration; | ||
import io.airbyte.migrate.MigrationUtils; | ||
import io.airbyte.migrate.ResourceId; | ||
import io.airbyte.migrate.ResourceType; | ||
import java.nio.file.Path; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.function.Consumer; | ||
import java.util.stream.Stream; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* This migration is currently empty and is a placeholder for migrations for the next 0.19.0 release | ||
* | ||
* Additionally, this migration updates the JSON Schema for StandardWorkspace with a new optional | ||
* field 'failureNotificationsWebhook' introduced in issue #1689 | ||
*/ | ||
public class MigrationV0_23_0 extends BaseMigration implements Migration { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(MigrationV0_23_0.class); | ||
|
||
private static final ResourceId SOURCE_DEFINITION_RESOURCE_ID = ResourceId.fromConstantCase(ResourceType.CONFIG, "STANDARD_SOURCE_DEFINITION"); | ||
private static final ResourceId DESTINATION_DEFINITION_RESOURCE_ID = | ||
ResourceId.fromConstantCase(ResourceType.CONFIG, "STANDARD_DESTINATION_DEFINITION"); | ||
private static final ResourceId STANDARD_SYNC_RESOURCE_ID = ResourceId.fromConstantCase(ResourceType.CONFIG, "STANDARD_SYNC"); | ||
|
||
private static final String MIGRATION_VERSION = "0.23.0-alpha"; | ||
|
||
private final Migration previousMigration; | ||
|
||
public MigrationV0_23_0(Migration previousMigration) { | ||
super(previousMigration); | ||
this.previousMigration = previousMigration; | ||
} | ||
|
||
@Override | ||
public String getVersion() { | ||
return MIGRATION_VERSION; | ||
} | ||
|
||
@Override | ||
public Map<ResourceId, JsonNode> getInputSchema() { | ||
return new HashMap<>(previousMigration.getOutputSchema()); | ||
} | ||
|
||
@Override | ||
public Map<ResourceId, JsonNode> getOutputSchema() { | ||
final Map<ResourceId, JsonNode> outputSchema = new HashMap<>(previousMigration.getOutputSchema()); | ||
outputSchema.put( | ||
SOURCE_DEFINITION_RESOURCE_ID, | ||
MigrationUtils.getSchemaFromResourcePath(Path.of("migrations/migrationV0_23_0"), SOURCE_DEFINITION_RESOURCE_ID)); | ||
outputSchema.put( | ||
DESTINATION_DEFINITION_RESOURCE_ID, | ||
MigrationUtils.getSchemaFromResourcePath(Path.of("migrations/migrationV0_23_0"), DESTINATION_DEFINITION_RESOURCE_ID)); | ||
outputSchema.put( | ||
STANDARD_SYNC_RESOURCE_ID, | ||
MigrationUtils.getSchemaFromResourcePath(Path.of("migrations/migrationV0_23_0"), STANDARD_SYNC_RESOURCE_ID)); | ||
return outputSchema; | ||
} | ||
|
||
@Override | ||
public void migrate(Map<ResourceId, Stream<JsonNode>> inputData, Map<ResourceId, Consumer<JsonNode>> outputData) { | ||
for (final Map.Entry<ResourceId, Stream<JsonNode>> entry : inputData.entrySet()) { | ||
final Consumer<JsonNode> recordConsumer = outputData.get(entry.getKey()); | ||
|
||
entry.getValue().forEach(r -> { | ||
// empty migration | ||
recordConsumer.accept(r); | ||
}); | ||
} | ||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...gration/src/main/resources/migrations/migrationV0_23_0/StandardDestinationDefinition.yaml
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
"$schema": http://json-schema.org/draft-07/schema# | ||
"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardDestinationDefinition.yaml | ||
title: StandardDestinationDefinition | ||
description: describes a destination | ||
type: object | ||
required: | ||
- destinationDefinitionId | ||
- name | ||
- dockerRepository | ||
- dockerImageTag | ||
- documentationUrl | ||
additionalProperties: false | ||
properties: | ||
destinationDefinitionId: | ||
type: string | ||
format: uuid | ||
name: | ||
type: string | ||
dockerRepository: | ||
type: string | ||
dockerImageTag: | ||
type: string | ||
documentationUrl: | ||
type: string | ||
icon: | ||
type: string |
27 changes: 27 additions & 0 deletions
27
...te-migration/src/main/resources/migrations/migrationV0_23_0/StandardSourceDefinition.yaml
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
"$schema": http://json-schema.org/draft-07/schema# | ||
"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/Source.yaml | ||
title: StandardSourceDefinition | ||
description: describes a source | ||
type: object | ||
required: | ||
- sourceDefinitionId | ||
- name | ||
- dockerRepository | ||
- dockerImageTag | ||
- documentationUrl | ||
additionalProperties: false | ||
properties: | ||
sourceDefinitionId: | ||
type: string | ||
format: uuid | ||
name: | ||
type: string | ||
dockerRepository: | ||
type: string | ||
dockerImageTag: | ||
type: string | ||
documentationUrl: | ||
type: string | ||
icon: | ||
type: string |
35 changes: 35 additions & 0 deletions
35
airbyte-migration/src/main/resources/migrations/migrationV0_23_0/StandardSync.yaml
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
"$schema": http://json-schema.org/draft-07/schema# | ||
"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardSync.yaml | ||
title: StandardSync | ||
description: configuration required for sync for ALL taps | ||
type: object | ||
required: | ||
- sourceId | ||
- destinationId | ||
- name | ||
- catalog | ||
additionalProperties: false | ||
properties: | ||
prefix: | ||
description: Prefix that will be prepended to the name of each stream when it is written to the destination. | ||
type: string | ||
sourceId: | ||
type: string | ||
format: uuid | ||
destinationId: | ||
type: string | ||
format: uuid | ||
connectionId: | ||
type: string | ||
format: uuid | ||
name: | ||
type: string | ||
catalog: | ||
existingJavaType: io.airbyte.protocol.models.ConfiguredAirbyteCatalog | ||
status: | ||
type: string | ||
enum: | ||
- active | ||
- inactive | ||
- deprecated |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: update this