mattyb149 commented on a change in pull request #4653:
URL: https://github.com/apache/nifi/pull/4653#discussion_r525341233



##########
File path: 
nifi-nar-bundles/nifi-hive-bundle/nifi-hive3-processors/src/main/java/org/apache/nifi/processors/hive/UpdateHive3Table.java
##########
@@ -0,0 +1,494 @@
+/*
+ * 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.hive;
+
+import org.apache.hadoop.hive.ql.io.orc.NiFiOrcUtils;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.RequiresInstanceClassLoading;
+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.components.AllowableValue;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.dbcp.hive.Hive3DBCPService;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.ProcessorInitializationContext;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processor.util.pattern.DiscontinuedException;
+import 
org.apache.nifi.processors.hadoop.exception.RecordReaderFactoryException;
+import org.apache.nifi.serialization.RecordReader;
+import org.apache.nifi.serialization.RecordReaderFactory;
+import org.apache.nifi.serialization.record.RecordField;
+import org.apache.nifi.serialization.record.RecordSchema;
+import org.apache.nifi.util.StringUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+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.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+
+@Tags({"hive", "metadata", "jdbc", "database", "table"})
+@CapabilityDescription("This processor uses a Hive JDBC connection and 
incoming records to generate any Hive 3.0+ table changes needed to support the 
incoming records.")
+@WritesAttributes({
+        @WritesAttribute(attribute = "metadata.output.table", description = 
"This attribute is written on the flow files routed to the 'success' "
+                + "and 'failure' relationships, and contains the target table 
name in 'databaseName.tableName' format."),
+        @WritesAttribute(attribute = "output.path", description = "This 
attribute is written on the flow files routed to the 'success' "
+                + "and 'failure' relationships, and contains the path on the 
file system to the table (or partition location if the table is partitioned).")
+})
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@RequiresInstanceClassLoading
+public class UpdateHive3Table extends AbstractProcessor {
+
+    static final String TEXTFILE = "TEXTFILE";
+    static final String SEQUENCEFILE = "SEQUENCEFILE";
+    static final String ORC = "ORC";
+    static final String PARQUET = "PARQUET";
+    static final String AVRO = "AVRO";
+    static final String RCFILE = "RCFILE";
+
+    static final AllowableValue TEXTFILE_STORAGE = new 
AllowableValue(TEXTFILE, TEXTFILE, "Stored as plain text files. TEXTFILE is the 
default file format, unless the configuration "
+            + "parameter hive.default.fileformat has a different setting.");
+    static final AllowableValue SEQUENCEFILE_STORAGE = new 
AllowableValue(SEQUENCEFILE, SEQUENCEFILE, "Stored as compressed Sequence 
Files.");
+    static final AllowableValue ORC_STORAGE = new AllowableValue(ORC, ORC, 
"Stored as ORC file format. Supports ACID Transactions & Cost-based Optimizer 
(CBO). "
+            + "Stores column-level metadata.");
+    static final AllowableValue PARQUET_STORAGE = new AllowableValue(PARQUET, 
PARQUET, "Stored as Parquet format for the Parquet columnar storage format.");
+    static final AllowableValue AVRO_STORAGE = new AllowableValue(AVRO, AVRO, 
"Stored as Avro format.");
+    static final AllowableValue RCFILE_STORAGE = new AllowableValue(RCFILE, 
RCFILE, "Stored as Record Columnar File format.");
+
+    static String ATTR_OUTPUT_TABLE = "metadata.output.table";
+    static String ATTR_OUTPUT_PATH = "output.path";
+
+    // Properties
+    static final PropertyDescriptor RECORD_READER = new 
PropertyDescriptor.Builder()
+            .name("record-reader")
+            .displayName("Record Reader")
+            .description("The service for reading records from incoming flow 
files.")
+            .identifiesControllerService(RecordReaderFactory.class)
+            .required(true)
+            .build();
+
+    static final PropertyDescriptor HIVE_DBCP_SERVICE = new 
PropertyDescriptor.Builder()
+            .name("hive3-dbcp-service")
+            .displayName("Hive Database Connection Pooling Service")
+            .description("The Hive Controller Service that is used to obtain 
connection(s) to the Hive database")
+            .required(true)
+            .identifiesControllerService(Hive3DBCPService.class)
+            .build();
+
+    static final PropertyDescriptor DB_NAME = new PropertyDescriptor.Builder()
+            .name("hive3-database-name")
+            .displayName("Database Name")
+            .description("The name of the database in which to put the data.")
+            .required(true)
+            
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            .build();
+
+    static final PropertyDescriptor TABLE_NAME = new 
PropertyDescriptor.Builder()
+            .name("hive3-table-name")
+            .displayName("Table Name")
+            .description("The name of the database table to update. If the 
table does not exist, then it will either be created or an error thrown, 
depending "
+                    + "on the value of the Create Table property.")
+            .required(true)
+            
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+            .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+            .build();
+
+    static final PropertyDescriptor CREATE_TABLE = new 
PropertyDescriptor.Builder()
+            .name("hive3-create-table")
+            .displayName("Create Table Strategy")
+            .description("Whether to create the table if it does not exist.")
+            .required(true)
+            .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
+            .allowableValues("true", "false")
+            .defaultValue("true")
+            .build();
+
+    static final PropertyDescriptor TABLE_STORAGE_FORMAT = new 
PropertyDescriptor.Builder()

Review comment:
       Good catch! I forgot the dependent properties PR has been merged, will 
update




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to