-
Notifications
You must be signed in to change notification settings - Fork 2.9k
NIFI-10403 Add processor supporting the new BigQuery Write API #6344
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
Closed
bejancsaba
wants to merge
6
commits into
apache:main
from
bejancsaba:NIFI-10403-Sink-BigQuery-new-Write-Api
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7ba8350
NIFI-10403 Add processor supporting the new BigQuery Write API
bejancsaba 641e854
NIFI-10403 Address review comments
bejancsaba fe2fa13
NIFI-10403 Exceptional case handling and extra tests around it
bejancsaba aeaf43b
NIFI-10403 Failing in OnScheduled in case of writeClient initialisati…
bejancsaba eb26ef0
NIFI-10403 Addresing review comments + date handling enhancements
bejancsaba 58e0b72
NIFI-10403 Enhance storage error logging
bejancsaba 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 hidden or 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 hidden or 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 hidden or 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
451 changes: 451 additions & 0 deletions
451
...ifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQuery.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
66 changes: 66 additions & 0 deletions
66
...cp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/proto/ProtoUtils.java
This file contains hidden or 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,66 @@ | ||
| /* | ||
| * 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.nifi.processors.gcp.bigquery.proto; | ||
|
|
||
| import com.google.protobuf.Descriptors; | ||
| import com.google.protobuf.DynamicMessage; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * Util class for protocol buffer messaging | ||
| */ | ||
| public class ProtoUtils { | ||
|
|
||
| public static DynamicMessage createMessage(Descriptors.Descriptor descriptor, Map<String, Object> valueMap) { | ||
| DynamicMessage.Builder builder = DynamicMessage.newBuilder(descriptor); | ||
|
|
||
| for (Descriptors.FieldDescriptor field : descriptor.getFields()) { | ||
| String name = field.getName(); | ||
| Object value = valueMap.get(name); | ||
| if (value == null) { | ||
| continue; | ||
| } | ||
|
|
||
| if (Descriptors.FieldDescriptor.Type.MESSAGE.equals(field.getType())) { | ||
| if (field.isRepeated()) { | ||
| Collection collection = value.getClass().isArray() ? Arrays.asList((Object[]) value) : (Collection) value; | ||
| collection.forEach(act -> builder.addRepeatedField(field, createMessage(field.getMessageType(), (Map<String, Object>) act))); | ||
| } else { | ||
| builder.setField(field, createMessage(field.getMessageType(), (Map<String, Object>) value)); | ||
| } | ||
| } else { | ||
| // Integer in the bigquery table schema maps back to INT64 which is considered to be Long on Java side: | ||
| // https://developers.google.com/protocol-buffers/docs/proto3 | ||
| if (value instanceof Integer && (field.getType() == Descriptors.FieldDescriptor.Type.INT64)) { | ||
| value = Long.valueOf((Integer) value); | ||
| } | ||
|
|
||
| if (field.isRepeated()) { | ||
| Collection collection = value.getClass().isArray() ? Arrays.asList((Object[]) value) : (Collection) value; | ||
| collection.forEach(act -> builder.addRepeatedField(field, act)); | ||
| } else { | ||
| builder.setField(field, value); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return builder.build(); | ||
| } | ||
| } |
This file contains hidden or 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
58 changes: 58 additions & 0 deletions
58
...resources/docs/org.apache.nifi.processors.gcp.bigquery.PutBigQuery/additionalDetails.html
This file contains hidden or 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,58 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en" xmlns="http://www.w3.org/1999/html"> | ||
| <!-- | ||
| 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. | ||
| --> | ||
|
|
||
| <head> | ||
| <meta charset="utf-8"/> | ||
| <title>PutBigQuery</title> | ||
| <link rel="stylesheet" href="../../../../../css/component-usage.css" type="text/css"/> | ||
| </head> | ||
| <body> | ||
|
|
||
| <h1>Streaming Versus Batching Data</h1> | ||
|
|
||
| <p> | ||
| PutBigQuery is record based and is relying on the gRPC based Write API using protocol buffers. The underlying stream supports both streaming and batching approaches. | ||
| </p> | ||
|
|
||
| <h3>Streaming</h3> | ||
| <p> | ||
| With streaming the appended data to the stream is instantly available in BigQuery for reading. It is configurable how many records (rows) should be appended at once. | ||
| Only one stream is established per flow file so at the conclusion of the FlowFile processing the used stream is closed and a new one is opened for the next FlowFile. | ||
| Supports exactly once delivery semantics via stream offsets. | ||
| </p> | ||
|
|
||
| <h3>Batching</h3> | ||
| <p> | ||
| Similarly to the streaming approach one stream is opened for each FlowFile and records are appended to the stream. However data is not available in BigQuery until it is | ||
| committed by the processor at the end of the FlowFile processing. | ||
| </p> | ||
|
|
||
| <h1>Improvement opportunities</h1> | ||
| <p> | ||
| <ul> | ||
| <li>The table has to exist on BigQuery side it is not created automatically</li> | ||
| <li>The Write API supports multiple streams for parallel execution and transactionality across streams. This is not utilized at the moment as this would be covered on NiFI framework level.</li> | ||
| </ul> | ||
| </p> | ||
|
|
||
| <p> | ||
| The official <a href="https://cloud.google.com/bigquery/docs/write-api">Google Write API documentation</a> provides additional details. | ||
| </p> | ||
|
|
||
|
|
||
| </body> | ||
| </html> |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.