[ 
https://issues.apache.org/jira/browse/HIVE-26744?focusedWorklogId=827563&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-827563
 ]

ASF GitHub Bot logged work on HIVE-26744:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Nov/22 12:48
            Start Date: 21/Nov/22 12:48
    Worklog Time Spent: 10m 
      Work Description: SourabhBadhya commented on code in PR #3774:
URL: https://github.com/apache/hive/pull/3774#discussion_r1027990680


##########
ql/src/java/org/apache/hadoop/hive/ql/udf/generic/AbstractGenericUDFArrayBase.java:
##########
@@ -0,0 +1,151 @@
+/*
+ * 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.hadoop.hive.ql.udf.generic;
+
+import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
+import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
+import org.apache.hadoop.hive.serde.serdeConstants;
+
+import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters;
+import 
org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorConverters.Converter;
+import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Abstract GenericUDF for array functions
+ */
+
+public abstract class AbstractGenericUDFArrayBase extends GenericUDF {
+
+    static final int ARRAY_IDX = 0;
+    static final int ARRAY2_IDX = 1;
+    static final int START_IDX = 1;
+    static final int LENGTH_IDX = 2;
+    static final int SEPARATOR_IDX = 1;
+    static final int REPLACE_NULL_IDX = 2;
+
+    private final int minArgCount;
+    private final int maxArgCount;
+    private final ObjectInspector.Category outputCategory;
+
+    private final FUNC_NAMES funcName;
+
+    transient ListObjectInspector arrayOI;
+    transient ObjectInspector[] argumentOIs;
+
+    transient Converter converter;
+
+    public AbstractGenericUDFArrayBase(FUNC_NAMES funcName, int minArgCount, 
int maxArgCount, ObjectInspector.Category outputCategory) {
+        this.funcName = funcName;
+        this.minArgCount = minArgCount;
+        this.maxArgCount = maxArgCount;
+        this.outputCategory = outputCategory;
+    }
+
+    enum FUNC_NAMES {
+        ARRAY_MAX, ARRAY_MIN, ARRAY_DISTINCT, ARRAY_SLICE, ARRAY_JOIN, 
ARRAY_EXCEPT, ARRAY_INTERSECT

Review Comment:
   I think this enum might not be required and we can call `initialize` in the 
sub-classes.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 827563)
    Time Spent: 2.5h  (was: 2h 20m)

> Add array_max and array_min UDFs 
> ---------------------------------
>
>                 Key: HIVE-26744
>                 URL: https://issues.apache.org/jira/browse/HIVE-26744
>             Project: Hive
>          Issue Type: Sub-task
>          Components: Hive
>            Reporter: Taraka Rama Rao Lethavadla
>            Assignee: Taraka Rama Rao Lethavadla
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2.5h
>  Remaining Estimate: 0h
>
> *1. array_max(array(obj1, obj2,...))* - The function returns the maximum 
> value in an array with elements for which order is supported, returns null if 
> array is empty
> Example:
> {noformat}
> > SELECT array_max(array(1, 3, 0, NULL)) FROM src LIMIT 1;
> 3{noformat}
>  
> *2. array_min(array(obj1, obj2,...))* - The function returns the minimum 
> value in an array with elements for which order is supported, returns null if 
> array is empty
> Example:  
> {noformat}
> > SELECT array_min(array(1, 3, 0, NULL)) FROM src LIMIT 1;
> 0{noformat}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to