Skip to content

Destination BigQuery: Accept Dataset ID field prefixed by Project ID - #8383

Merged
mkhokh-33 merged 17 commits into
airbytehq:masterfrom
koji-m:parsing-dataset-names-in-bq
Jan 18, 2022
Merged

mkhokh-33 merged 17 commits into
airbytehq:masterfrom
koji-m:parsing-dataset-names-in-bq

Conversation

@koji-m

@koji-m Koji Matsumoto (koji-m) commented Dec 1, 2021 •

Copy link
Copy Markdown
Contributor

What

Closes: #1192

How

In the BigQuery destination connector's Dataset ID field, we could accept both syntax:

  • project-id:dataset_id
  • dataset_id

Make it error, if project-id in the Dataset ID field doesn't match the value in the Project ID field.

Recommended reading order

  1. BigQueryDestinationTest.java
  2. BigQueryDestination.java

Pre-merge Checklist

Expand the relevant checklist and delete the others.

Updating a connector

Community member or Airbyter

  • Grant edit access to maintainers (instructions)
  • Secrets in the connector's spec are annotated with airbyte_secret
  • Unit & integration tests added and passing. Community members, please provide proof of success locally e.g: screenshot or copy-paste unit, integration, and acceptance test output. To run acceptance tests for a Python connector, follow instructions in the README. For java connectors run ./gradlew :airbyte-integrations:connectors:<name>:integrationTest.
  • Code reviews completed
  • Documentation updated
    • Connector's README.md
    • Connector's bootstrap.md. See description and examples
    • Changelog updated in docs/integrations/<source or destination>/<name>.md including changelog. See changelog example
  • PR name follows PR naming conventions

Airbyter

If this is a community PR, the Airbyte engineer reviewing this PR is responsible for the below items.

  • Create a non-forked branch based on this PR and test the below items on it
  • Build is successful
  • Credentials added to Github CI. Instructions.
  • /test connector=connectors/<name> command is passing.
  • New Connector version released on Dockerhub by running the /publish command described here
  • After the new connector version is published, connector version bumped in the seed directory as described here
  • Seed specs have been re-generated by building the platform and committing the changes to the seed spec files, as described here

スクリーンショット 2021-12-01 23 12 40


This change is Reviewable

@github-actions github-actions Bot added the area/documentation Improvements or additions to documentation label Dec 1, 2021
@mkhokh-33 mkhokh-33 assigned mkhokh-33 and unassigned mkhokh-33 Dec 20, 2021
@mkhokh-33

Copy link
Copy Markdown
Contributor

Hi, Koji Matsumoto (@koji-m) could you please update the branch and resolve conflicts on PR, tnx

@koji-m

Copy link
Copy Markdown
Contributor Author

Hi, mkhokh-33
I've updated the branch and resolved conflicts. And integration-test passed at local.
Please review.


private static final Logger LOGGER = LoggerFactory.getLogger(BigQueryUtils.class);
private static final String BIG_QUERY_DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss.SSSSSS";
private static final Pattern datasetIdPattern = Pattern.compile("^(([a-z]([a-z0-9\\-]*[a-z0-9])?):)?([a-zA-Z0-9_]+)$");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems to be a constant
pls, rename it to DATASET_ID_PATTERN

.put(BigQueryConsts.CONFIG_DATASET_LOCATION, "US");
}

public static Stream<Arguments> validBigQueryIdProvider() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change method definition to private and move below the public methods

assertEquals(expected, actual);
}

public static Stream<Arguments> invalidBigQueryIdProvider() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change method definition to private and move below the public methods


public static Stream<Arguments> invalidBigQueryIdProvider() {
return Stream.of(
Arguments.arguments("my-project", ":my_dataset", "BigQuery Dataset ID format must match '[project-id:]dataset_id': :my_dataset"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to check regexp pattern for dataset we could also add here some other incorrect datasets:
1."my-project:my-project:my_dataset".(to check that ':' is not allowed inside project name)
2."my-project-:my_dataset". (project name cannot end with a hyphen)
3."my-project:"
3."my-project: "

public AirbyteConnectionStatus check(final JsonNode config) {
try {
final String datasetId = config.get(BigQueryConsts.CONFIG_DATASET_ID).asText();
final String datasetId = BigQueryUtils.getDatasetId(config);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BigQueryUtils.getDatasetId(config) used in 2 cases

  1. BigQueryDestination.check()
  2. BigQueryDestination.getConsumer() invoke inside BigQueryUploaderFactory.getUploader then BigQueryUtils.getSchema then BigQueryUtils.getDatasetId(config)

Could you pls consider to add integration test to BigQueryDestinationTest to check that:

  1. we can create connection with provided dataset
  2. we can get consumer and write some data

@mkhokh-33

Copy link
Copy Markdown
Contributor

Hi, mkhokh-33 I've updated the branch and resolved conflicts. And integration-test passed at local. Please review.

hi Koji Matsumoto (@koji-m), thanks for your PR, I left some comments

@koji-m

Copy link
Copy Markdown
Contributor Author

mkhokh-33 Thank you for your review. I've fixed based on your review.

@mkhokh-33
mkhokh-33 temporarily deployed to more-secrets January 4, 2022 14:21 Inactive
@jrhizor
Jared Rhizor (jrhizor) temporarily deployed to more-secrets January 4, 2022 14:43 Inactive
@jrhizor
Jared Rhizor (jrhizor) temporarily deployed to more-secrets January 4, 2022 14:43 Inactive
@mkhokh-33
mkhokh-33 temporarily deployed to more-secrets January 4, 2022 14:52 Inactive
@mkhokh-33
mkhokh-33 temporarily deployed to more-secrets January 4, 2022 15:25 Inactive
@mkhokh-33

Copy link
Copy Markdown
Contributor

LGTM,
connectors base fails is known issue will be fixed by - #9274
Sherif A. Nada (@sherifnada) could you have a look please, integration test are passed - #9282

@koji-m

Copy link
Copy Markdown
Contributor Author

Edward Gao (@edgao) Thank you for your review. I've fixed based on your review.

@edgao Edward Gao (edgao) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! mkhokh-33 can you take care of releasing this?

@edgao

Copy link
Copy Markdown
Contributor

actually, lemme publish a separate PR first, will comment here once that finishes

@edgao

Copy link
Copy Markdown
Contributor

alright mkhokh-33 we're good to go here!

@mkhokh-33

mkhokh-33 commented Jan 10, 2022 •

Copy link
Copy Markdown
Contributor

Hi Koji Matsumoto (@koji-m) ,
could you please update docker images version in following files:

  1. https://github.com/koji-m/airbyte/blob/parsing-dataset-names-in-bq/airbyte-integrations/connectors/destination-bigquery/Dockerfile

LABEL io.airbyte.version=0.6.2

we also need to change version for destination-bigquery-denormalized cause it uses destination-bigquery implementation
2. https://github.com/koji-m/airbyte/blob/parsing-dataset-names-in-bq/airbyte-integrations/connectors/destination-bigquery-denormalized/Dockerfile

LABEL io.airbyte.version=0.2.3

  1. https://github.com/koji-m/airbyte/blob/parsing-dataset-names-in-bq/airbyte-config/init/src/main/resources/seed/destination_definitions.yaml
  • dockerImage: "airbyte/destination-bigquery:0.6.2"
  • dockerImage: "airbyte/destination-bigquery-denormalized:0.2.3"
  1. https://github.com/koji-m/airbyte/blob/parsing-dataset-names-in-bq/airbyte-config/init/src/main/resources/config/STANDARD_DESTINATION_DEFINITION/22f6c74f-5699-40ff-833c-4a879ea40133.json "dockerImageTag": "0.6.2",

  2. https://github.com/koji-m/airbyte/blob/parsing-dataset-names-in-bq/airbyte-config/init/src/main/resources/config/STANDARD_DESTINATION_DEFINITION/079d5540-f236-4294-ba7c-ade8fd918496.json

"dockerImageTag": "0.2.3",

  1. https://github.com/koji-m/airbyte/blob/parsing-dataset-names-in-bq/airbyte-config/init/src/main/resources/seed/destination_specs.yaml
    -dockerImage: "airbyte/destination-bigquery:0.6.2
  • dockerImage: "airbyte/destination-bigquery-denormalized:0.2.3"

Thus I could proceed with merge. Thanks

@koji-m

Copy link
Copy Markdown
Contributor Author

mkhokh-33 Sorry for the late response. I've updated the docker image version numbers. (with docs)

  • destination-bigquery: 0.6.3 (master) -> 0.6.4 (this branch)
  • destination-bigquery-denormalized: 0.2.3 (master) -> 0.2.4 (this branch)

@mkhokh-33
mkhokh-33 temporarily deployed to more-secrets January 17, 2022 11:32 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 17, 2022 11:34 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 17, 2022 11:35 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 17, 2022 12:15 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 17, 2022 12:15 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 17, 2022 12:21 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 17, 2022 13:43 Inactive
@mkhokh-33
mkhokh-33 temporarily deployed to more-secrets January 18, 2022 08:38 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 18, 2022 08:59 Inactive
@octavia-squidington-iii
Octavia Squidington III (octavia-squidington-iii) temporarily deployed to more-secrets January 18, 2022 09:10 Inactive
@mkhokh-33
mkhokh-33 temporarily deployed to more-secrets January 18, 2022 09:41 Inactive
@mkhokh-33
mkhokh-33 merged commit 3f9cbec into airbytehq:master Jan 18, 2022
@mkhokh-33

Copy link
Copy Markdown
Contributor

mkhokh-33 Sorry for the late response. I've updated the docker image version numbers. (with docs)

  • destination-bigquery: 0.6.3 (master) -> 0.6.4 (this branch)
  • destination-bigquery-denormalized: 0.2.3 (master) -> 0.2.4 (this branch)

Koji Matsumoto (@koji-m) thank you, merged 👍

This branch was previously deployed

1 inactive deployment
more-secrets — 5eefebec Deployed Jan 18, 2022 by mkhokh-33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parsing Dataset names in BigQuery

7 participants