forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Destination BigQuery: Accept Dataset ID field prefixed by Project ID (a…
…irbytehq#8383) * add Dataset ID parse method * add BigQuery Destination unit test * update change log * fit to the latest code base * update change log * change var name to const name * change public method to private * add test cases for testGetDatasetIdFail * add integration test for dataset-id prefixed with project-id * fix getDatasetId * add comment to parameterized test provider * update docker image versions * update docker image versions again
- Loading branch information
Showing
11 changed files
with
152 additions
and
20 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
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
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
69 changes: 69 additions & 0 deletions
69
...igquery/src/test/java/io/airbyte/integrations/destination/bigquery/BigQueryUtilsTest.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,69 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination.bigquery; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.airbyte.commons.json.Jsons; | ||
import java.util.stream.Stream; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.Arguments; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
public class BigQueryUtilsTest { | ||
|
||
private ImmutableMap.Builder<Object, Object> configMapBuilder; | ||
|
||
@BeforeEach | ||
public void init() { | ||
configMapBuilder = ImmutableMap.builder() | ||
.put(BigQueryConsts.CONFIG_CREDS, "test_secret") | ||
.put(BigQueryConsts.CONFIG_DATASET_LOCATION, "US"); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("validBigQueryIdProvider") | ||
public void testGetDatasetIdSuccess(String projectId, String datasetId, String expected) throws Exception { | ||
JsonNode config = Jsons.jsonNode(configMapBuilder | ||
.put(BigQueryConsts.CONFIG_PROJECT_ID, projectId) | ||
.put(BigQueryConsts.CONFIG_DATASET_ID, datasetId) | ||
.build()); | ||
|
||
String actual = BigQueryUtils.getDatasetId(config); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("invalidBigQueryIdProvider") | ||
public void testGetDatasetIdFail(String projectId, String datasetId, String expected) throws Exception { | ||
JsonNode config = Jsons.jsonNode(configMapBuilder | ||
.put(BigQueryConsts.CONFIG_PROJECT_ID, projectId) | ||
.put(BigQueryConsts.CONFIG_DATASET_ID, datasetId) | ||
.build()); | ||
|
||
Exception exception = assertThrows(IllegalArgumentException.class, () -> BigQueryUtils.getDatasetId(config)); | ||
|
||
assertEquals(expected, exception.getMessage()); | ||
} | ||
|
||
private static Stream<Arguments> validBigQueryIdProvider() { | ||
return Stream.of( | ||
Arguments.arguments("my-project", "my_dataset", "my_dataset"), | ||
Arguments.arguments("my-project", "my-project:my_dataset", "my_dataset")); | ||
} | ||
|
||
private static Stream<Arguments> invalidBigQueryIdProvider() { | ||
return Stream.of( | ||
Arguments.arguments("my-project", ":my_dataset", | ||
"Project ID included in Dataset ID must match Project ID field's value: Project ID is `my-project`, but you specified `` in Dataset ID"), | ||
Arguments.arguments("my-project", "your-project:my_dataset", | ||
"Project ID included in Dataset ID must match Project ID field's value: Project ID is `my-project`, but you specified `your-project` in Dataset ID")); | ||
} | ||
} |
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