-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
🎉 Destination-snowflake: start using new S3StreamCopier, and expose the purgeStagingData option #9531
Merged
etsybaev
merged 11 commits into
master
from
etsybaev/8820-destination-snowlake-use-new-stream-copier
Jan 20, 2022
Merged
🎉 Destination-snowflake: start using new S3StreamCopier, and expose the purgeStagingData option #9531
Changes from 2 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dfb0d46
[8820] Destination-snowflake: start using new S3StreamCopier, and exp…
etsybaev 26b7cac
Merge branch 'master' into etsybaev/8820-destination-snowlake-use-new…
etsybaev 66d5f1b
Fixed code as per comments in PR
etsybaev 087a7a4
Merge branch 'master' into etsybaev/8820-destination-snowlake-use-new…
etsybaev ee4a894
Fixed code as per comments in PR(2)
etsybaev 010f36f
minor refactor + fix code style
etsybaev e4abe14
Extended test to check all staging files
etsybaev 715a1a0
Merge branch 'master' into etsybaev/8820-destination-snowlake-use-new…
etsybaev a83204a
Merge branch 'master' into etsybaev/8820-destination-snowlake-use-new…
etsybaev 45323cb
Updated documentation and bumped version
etsybaev e00aa92
Updated destination-spec
etsybaev 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
87 changes: 87 additions & 0 deletions
87
.../test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.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,87 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.snowflake; | ||
|
||
import static io.airbyte.integrations.destination.snowflake.SnowflakeS3StreamCopier.MAX_PARTS_PER_FILE; | ||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import com.amazonaws.services.s3.AmazonS3Client; | ||
import io.airbyte.db.jdbc.JdbcDatabase; | ||
import io.airbyte.integrations.destination.ExtendedNameTransformer; | ||
import io.airbyte.integrations.destination.jdbc.SqlOperations; | ||
import io.airbyte.integrations.destination.jdbc.copy.s3.S3CopyConfig; | ||
import io.airbyte.integrations.destination.s3.S3DestinationConfig; | ||
import io.airbyte.protocol.models.AirbyteStream; | ||
import io.airbyte.protocol.models.ConfiguredAirbyteStream; | ||
import io.airbyte.protocol.models.DestinationSyncMode; | ||
import java.sql.Timestamp; | ||
import java.time.Instant; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class SnowflakeS3StreamCopierTest { | ||
|
||
private static final int PART_SIZE = 5; | ||
|
||
// equivalent to Thu, 09 Dec 2021 19:17:54 GMT | ||
private static final Timestamp UPLOAD_TIME = Timestamp.from(Instant.ofEpochMilli(1639077474000L)); | ||
|
||
private AmazonS3Client s3Client; | ||
private JdbcDatabase db; | ||
private SqlOperations sqlOperations; | ||
private SnowflakeS3StreamCopier copier; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
s3Client = mock(AmazonS3Client.class, RETURNS_DEEP_STUBS); | ||
db = mock(JdbcDatabase.class); | ||
sqlOperations = mock(SqlOperations.class); | ||
|
||
copier = new SnowflakeS3StreamCopier( | ||
// In reality, this is normally a UUID - see CopyConsumerFactory#createWriteConfigs | ||
"fake-staging-folder", | ||
"fake-schema", | ||
s3Client, | ||
db, | ||
new S3CopyConfig( | ||
true, | ||
new S3DestinationConfig( | ||
"fake-endpoint", | ||
"fake-bucket", | ||
"fake-bucketPath", | ||
"fake-region", | ||
"fake-access-key-id", | ||
"fake-secret-access-key", | ||
PART_SIZE, | ||
null)), | ||
new ExtendedNameTransformer(), | ||
sqlOperations, | ||
UPLOAD_TIME, | ||
new ConfiguredAirbyteStream() | ||
.withDestinationSyncMode(DestinationSyncMode.APPEND) | ||
.withStream(new AirbyteStream() | ||
.withName("fake-stream") | ||
.withNamespace("fake-namespace"))); | ||
} | ||
|
||
@Test | ||
public void copiesCorrectFilesToTable() throws Exception { | ||
// Generate two files | ||
for (int i = 0; i < MAX_PARTS_PER_FILE + 1; i++) { | ||
copier.prepareStagingFile(); | ||
} | ||
|
||
copier.copyStagingFileToTemporaryTable(); | ||
|
||
verify(db).execute(String.format("COPY INTO fake-schema.%s FROM " | ||
edgao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
+ "'s3://fake-bucket/%s'" | ||
+ " CREDENTIALS=(aws_key_id='fake-access-key-id' aws_secret_key='fake-secret-access-key') " | ||
+ "file_format = (type = csv field_delimiter = ',' skip_header = 0 FIELD_OPTIONALLY_ENCLOSED_BY = '\"');", | ||
copier.getTmpTableName(), copier.getCurrentFile())); | ||
} | ||
|
||
} |
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.
Should this be
secrets/internal_staging_config
?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.
Have no idea :) I just aligned documentation to what we actually have in codebase and secret manager