[ https://issues.apache.org/jira/browse/HIVE-26774?focusedWorklogId=836812&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-836812 ]
ASF GitHub Bot logged work on HIVE-26774: ----------------------------------------- Author: ASF GitHub Bot Created on: 04/Jan/23 06:39 Start Date: 04/Jan/23 06:39 Worklog Time Spent: 10m Work Description: tarak271 commented on code in PR #3893: URL: https://github.com/apache/hive/pull/3893#discussion_r1061172528 ########## ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFArraySlice.java: ########## @@ -0,0 +1,73 @@ +/* + * 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.Description; +import org.apache.hadoop.hive.ql.exec.UDFArgumentException; +import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.IntObjectInspector; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * GenericUDFArraySlice. + */ +@Description(name = "array_slice", value = "_FUNC_(array, start, length) - Returns the subset or range of elements from" Review Comment: Tried to make the implementation similar to that of Spark's Slice function wherever possible, https://spark.apache.org/docs/latest/api/sql/#slice Please note that negative indexing is not implemented as we don't have it either in Hive or in Java Issue Time Tracking ------------------- Worklog Id: (was: 836812) Time Spent: 1h 10m (was: 1h) > Implement array_slice UDF to get the subset of elements from an array > (subarray) > -------------------------------------------------------------------------------- > > Key: HIVE-26774 > URL: https://issues.apache.org/jira/browse/HIVE-26774 > Project: Hive > Issue Type: Sub-task > Components: Hive > Reporter: Taraka Rama Rao Lethavadla > Assignee: Taraka Rama Rao Lethavadla > Priority: Minor > Labels: pull-request-available > Time Spent: 1h 10m > Remaining Estimate: 0h > > *array_slice(array, start, length)* - Returns the subset or range of elements > from an array (subarray). > Example: > > {noformat} > > SELECT array_slice(array(1, 2, 3,4), 2,2) FROM src LIMIT 1; > 3,4{noformat} > Returns empty list if start/length are out of range of the array -- This message was sent by Atlassian Jira (v8.20.10#820010)