-
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
Managed BigQueryIO #31486
Merged
Merged
Managed BigQueryIO #31486
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ce14b96
managed bigqueryio
ahmedabu98 550c1b4
spotless
ahmedabu98 c94de3c
move managed dependency to test only
ahmedabu98 912dc08
Merge branch 'master' of https://github.com/ahmedabu98/beam into mana…
ahmedabu98 f436e62
cleanup after merging snake_case PR
ahmedabu98 fe60904
choose write method based on boundedness and pipeline options
ahmedabu98 7d405cf
Merge branch 'master' of https://github.com/ahmedabu98/beam into mana…
ahmedabu98 d45159f
rename bigquery write config class
ahmedabu98 989ad0f
spotless
ahmedabu98 b9b49e7
change read output tag to 'output'
ahmedabu98 a119bbc
spotless
ahmedabu98 74bc178
revert logic that depends on DataflowServiceOptions. switching BQ met…
ahmedabu98 528b504
spotless
ahmedabu98 dcc398a
fix typo
ahmedabu98 36edc38
separate BQ write config to a new class
ahmedabu98 f9be86c
fix doc
ahmedabu98 bd1e534
Merge branch 'master' of https://github.com/ahmedabu98/beam into mana…
ahmedabu98 a26765e
resolve after syncing to HEAD
ahmedabu98 725f7bd
spotless
ahmedabu98 2631104
fork on batch/streaming
ahmedabu98 770cf50
cleanup
ahmedabu98 0a70466
spotless
ahmedabu98 01a01f7
move forking logic to BQ schematransform side
ahmedabu98 697c0b8
add file loads translation and tests; add test checks that the correc…
ahmedabu98 105474b
set top-level wrapper to be the underlying managed BQ transform urn; …
ahmedabu98 d6b9e69
move unit tests to respectvie schematransform test classes
ahmedabu98 c0767d7
Merge branch 'master' of https://github.com/ahmedabu98/beam into mana…
ahmedabu98 a600f62
Merge branch 'master' of https://github.com/ahmedabu98/beam into mana…
ahmedabu98 ad4dcd9
expose to Python SDK as well
ahmedabu98 6f325ce
Merge branch 'master' of https://github.com/ahmedabu98/beam into mana…
ahmedabu98 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,6 @@ | |
package org.apache.beam.sdk.io.gcp.bigquery.providers; | ||
|
||
import static org.apache.beam.sdk.io.gcp.bigquery.providers.BigQueryWriteConfiguration.DYNAMIC_DESTINATIONS; | ||
import static org.apache.beam.sdk.util.construction.BeamUrns.getUrn; | ||
import static org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.base.Preconditions.checkArgument; | ||
|
||
import com.google.api.services.bigquery.model.TableConstraints; | ||
|
@@ -28,7 +27,6 @@ | |
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import org.apache.beam.model.pipeline.v1.ExternalTransforms; | ||
import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO; | ||
import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.CreateDisposition; | ||
import org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.Write.Method; | ||
|
@@ -100,7 +98,7 @@ protected SchemaTransform from(BigQueryWriteConfiguration configuration) { | |
|
||
@Override | ||
public String identifier() { | ||
return getUrn(ExternalTransforms.ManagedTransforms.Urns.BIGQUERY_STORAGE_WRITE); | ||
return "beam:schematransform:org.apache.beam:bigquery_storage_write:v2"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
} | ||
|
||
@Override | ||
|
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
70 changes: 70 additions & 0 deletions
70
...a/org/apache/beam/sdk/io/gcp/bigquery/providers/BigQueryWriteSchemaTransformProvider.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,70 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.beam.sdk.io.gcp.bigquery.providers; | ||
|
||
import static org.apache.beam.sdk.util.construction.BeamUrns.getUrn; | ||
|
||
import com.google.auto.service.AutoService; | ||
import org.apache.beam.model.pipeline.v1.ExternalTransforms; | ||
import org.apache.beam.sdk.annotations.Internal; | ||
import org.apache.beam.sdk.schemas.transforms.SchemaTransform; | ||
import org.apache.beam.sdk.schemas.transforms.SchemaTransformProvider; | ||
import org.apache.beam.sdk.schemas.transforms.TypedSchemaTransformProvider; | ||
import org.apache.beam.sdk.values.PCollection; | ||
import org.apache.beam.sdk.values.PCollectionRowTuple; | ||
|
||
/** | ||
* A BigQuery Write SchemaTransformProvider that routes to either {@link | ||
* BigQueryFileLoadsWriteSchemaTransformProvider} or {@link | ||
* BigQueryStorageWriteApiSchemaTransformProvider}. | ||
* | ||
* <p>Internal only. Used by the Managed Transform layer. | ||
*/ | ||
@Internal | ||
@AutoService(SchemaTransformProvider.class) | ||
public class BigQueryWriteSchemaTransformProvider | ||
extends TypedSchemaTransformProvider<BigQueryWriteConfiguration> { | ||
@Override | ||
public String identifier() { | ||
return getUrn(ExternalTransforms.ManagedTransforms.Urns.BIGQUERY_WRITE); | ||
} | ||
|
||
@Override | ||
protected SchemaTransform from(BigQueryWriteConfiguration configuration) { | ||
return new BigQueryWriteRouter(configuration); | ||
} | ||
|
||
static class BigQueryWriteRouter extends SchemaTransform { | ||
private final BigQueryWriteConfiguration configuration; | ||
|
||
BigQueryWriteRouter(BigQueryWriteConfiguration configuration) { | ||
configuration.validate(); | ||
this.configuration = configuration; | ||
} | ||
|
||
@Override | ||
public PCollectionRowTuple expand(PCollectionRowTuple input) { | ||
if (input.getSinglePCollection().isBounded().equals(PCollection.IsBounded.BOUNDED)) { | ||
return input.apply(new BigQueryFileLoadsWriteSchemaTransformProvider().from(configuration)); | ||
} else { // UNBOUNDED | ||
return input.apply( | ||
new BigQueryStorageWriteApiSchemaTransformProvider().from(configuration)); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.
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.
I think it's still fine to define these URNs in the proto.
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.
I feel like we don't need to right now? Since we're using a wrapper over file loads and storage api writes
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.
May be will be useful for any Python wrappers that directly use specific schema-transforms ?
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.
In that case maybe we can do this in a separate PR that targets all schematransforms?