[ 
https://issues.apache.org/jira/browse/NIFI-4731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16474503#comment-16474503
 ] 

ASF GitHub Bot commented on NIFI-4731:
--------------------------------------

Github user zenfenan commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2682#discussion_r188032966
  
    --- Diff: 
nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery/PutBigQueryStream.java
 ---
    @@ -0,0 +1,360 @@
    +/*
    + * 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;
    +
    +import com.google.cloud.bigquery.BigQuery;
    +import com.google.cloud.bigquery.BigQueryError;
    +import com.google.cloud.bigquery.InsertAllRequest;
    +import com.google.cloud.bigquery.InsertAllResponse;
    +import com.google.cloud.bigquery.JobInfo;
    +import com.google.cloud.bigquery.Schema;
    +import com.google.cloud.bigquery.StandardTableDefinition;
    +import com.google.cloud.bigquery.Table;
    +import com.google.cloud.bigquery.TableId;
    +import com.google.cloud.bigquery.TableInfo;
    +import com.google.common.collect.ImmutableList;
    +import com.google.gson.Gson;
    +import com.google.gson.reflect.TypeToken;
    +import java.io.IOException;
    +import java.io.InputStreamReader;
    +import java.lang.reflect.Type;
    +import java.util.ArrayList;
    +import java.util.Arrays;
    +import java.util.Collections;
    +import java.util.HashMap;
    +import java.util.HashSet;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Map.Entry;
    +import java.util.Set;
    +import java.util.concurrent.TimeUnit;
    +import org.apache.nifi.annotation.behavior.InputRequirement;
    +import org.apache.nifi.annotation.behavior.WritesAttribute;
    +import org.apache.nifi.annotation.behavior.WritesAttributes;
    +import org.apache.nifi.annotation.documentation.CapabilityDescription;
    +import org.apache.nifi.annotation.documentation.Tags;
    +import org.apache.nifi.annotation.lifecycle.OnScheduled;
    +import org.apache.nifi.annotation.lifecycle.OnStopped;
    +import org.apache.nifi.components.PropertyDescriptor;
    +import org.apache.nifi.expression.ExpressionLanguageScope;
    +import org.apache.nifi.flowfile.FlowFile;
    +import org.apache.nifi.processor.DataUnit;
    +import org.apache.nifi.processor.ProcessContext;
    +import org.apache.nifi.processor.ProcessSession;
    +import org.apache.nifi.processor.Relationship;
    +import org.apache.nifi.processor.exception.ProcessException;
    +import org.apache.nifi.processor.util.StandardValidators;
    +
    +/**
    + *
    + */
    +
    +@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
    +@Tags({"google", "google cloud", "bq", "bigquery"})
    +@CapabilityDescription("Streams flow files to a Google BigQuery table.")
    +
    +@WritesAttributes({
    +    @WritesAttribute(attribute = BigQueryAttributes.DATASET_ATTR, 
description = BigQueryAttributes.DATASET_DESC),
    +    @WritesAttribute(attribute = BigQueryAttributes.TABLE_NAME_ATTR, 
description = BigQueryAttributes.TABLE_NAME_DESC),
    +    @WritesAttribute(attribute = BigQueryAttributes.TABLE_SCHEMA_ATTR, 
description = BigQueryAttributes.TABLE_SCHEMA_DESC),
    +    @WritesAttribute(attribute = BigQueryAttributes.BATCH_SIZE_ATTR, 
description = BigQueryAttributes.BATCH_SIZE_DESC),
    +    @WritesAttribute(attribute = BigQueryAttributes.MAX_ROW_SIZE_ATTR, 
description = BigQueryAttributes.MAX_ROW_SIZE_DESC),
    +    @WritesAttribute(attribute = 
BigQueryAttributes.CREATE_DISPOSITION_ATTR, description = 
BigQueryAttributes.CREATE_DISPOSITION_DESC),
    +    @WritesAttribute(attribute = 
BigQueryAttributes.TABLE_CACHE_RESET_ATTR, description = 
BigQueryAttributes.TABLE_CACHE_RESET_DESC),
    +    @WritesAttribute(attribute = BigQueryAttributes.JOB_ERROR_MSG_ATTR, 
description = BigQueryAttributes.JOB_ERROR_MSG_DESC),
    +    @WritesAttribute(attribute = BigQueryAttributes.JOB_ERROR_REASON_ATTR, 
description = BigQueryAttributes.JOB_ERROR_REASON_DESC),
    +    @WritesAttribute(attribute = 
BigQueryAttributes.JOB_ERROR_LOCATION_ATTR, description = 
BigQueryAttributes.JOB_ERROR_LOCATION_DESC)
    +})
    +
    +public class PutBigQueryStream extends AbstractBigQueryProcessor {
    +    public static final Relationship REL_ROW_TOO_BIG =
    +        new Relationship.Builder().name("row_too_big")
    +                .description("FlowFiles are routed to this relationship if 
the row size is too big.")
    +                .build();
    +
    +    public static final PropertyDescriptor DATASET = new PropertyDescriptor
    +        .Builder().name(BigQueryAttributes.DATASET_ATTR)
    +        .displayName("Dataset")
    +        .description(BigQueryAttributes.DATASET_DESC)
    +        .required(true)
    +        .defaultValue("${" + BigQueryAttributes.DATASET_ATTR + "}")
    +        
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
    +        .addValidator(StandardValidators.NON_EMPTY_EL_VALIDATOR)
    +        .build();
    +
    +    public static final PropertyDescriptor TABLE_NAME = new 
PropertyDescriptor
    +        .Builder().name(BigQueryAttributes.TABLE_NAME_ATTR)
    +        .displayName("Table Name")
    +        .description(BigQueryAttributes.TABLE_NAME_DESC)
    +        .required(true)
    +        .defaultValue("${" + BigQueryAttributes.TABLE_NAME_ATTR + "}")
    +        
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
    +        .addValidator(StandardValidators.NON_EMPTY_EL_VALIDATOR)
    +        .build();
    +
    +    public static final PropertyDescriptor TABLE_SCHEMA = new 
PropertyDescriptor
    --- End diff --
    
    I think `TABLE_SCHEMA`, `DATASET`, `TABLE_NAME` can be moved to the 
`AbstractBigQueryProcessor`


> BigQuery processors
> -------------------
>
>                 Key: NIFI-4731
>                 URL: https://issues.apache.org/jira/browse/NIFI-4731
>             Project: Apache NiFi
>          Issue Type: New Feature
>          Components: Extensions
>            Reporter: Mikhail Sosonkin
>            Priority: Major
>
> NIFI should have processors for putting data into BigQuery (Streaming and 
> Batch).
> Initial working processors can be found this repository: 
> https://github.com/nologic/nifi/tree/NIFI-4731/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/bigquery
> I'd like to get them into Nifi proper.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to