[ https://issues.apache.org/jira/browse/HIVE-25403?focusedWorklogId=634641&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-634641 ]
ASF GitHub Bot logged work on HIVE-25403: ----------------------------------------- Author: ASF GitHub Bot Created on: 05/Aug/21 16:18 Start Date: 05/Aug/21 16:18 Worklog Time Spent: 10m Work Description: warriersruthi commented on a change in pull request #2550: URL: https://github.com/apache/hive/pull/2550#discussion_r683601956 ########## File path: ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFFromUnixTime.java ########## @@ -0,0 +1,132 @@ +/* + * 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 java.time.ZoneId; +import org.apache.hadoop.hive.common.type.Date; +import org.apache.hadoop.hive.common.type.Timestamp; +import org.apache.hadoop.hive.common.type.TimestampTZ; +import org.apache.hadoop.hive.common.type.TimestampTZUtil; +import org.apache.hadoop.hive.conf.HiveConf; +import org.apache.hadoop.hive.ql.exec.MapredContext; +import org.apache.hadoop.hive.ql.metadata.HiveException; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredJavaObject; +import org.apache.hadoop.hive.ql.udf.generic.GenericUDF.DeferredObject; +import org.apache.hadoop.hive.serde2.io.DateWritableV2; +import org.apache.hadoop.hive.serde2.io.TimestampWritableV2; +import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; +import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory; +import org.apache.hadoop.io.LongWritable; +import org.apache.hadoop.io.Text; + +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.when; + +import org.apache.hadoop.mapred.JobConf; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.DateTimeFormatterBuilder; +import org.junit.Test; +import org.mockito.Mockito; + +/** + * TestGenericUDFFromUnixTime. + */ +public class TestGenericUDFFromUnixTime { + + public static void runAndVerify(GenericUDFFromUnixTime udf, + Object arg, Object expected) throws HiveException { + DeferredObject[] args = { new DeferredJavaObject(arg) }; + Object result = udf.evaluate(args); + if (expected == null) { + assertNull(result); + } else { + assertEquals(expected.toString(), result.toString()); + } + } + + public static void runAndVerify(GenericUDFFromUnixTime udf, + Object arg1, Object arg2, Object expected) throws HiveException { + DeferredObject[] args = { new DeferredJavaObject(arg1), new DeferredJavaObject(arg2) }; + Object result = udf.evaluate(args); + + if (expected == null) { + assertNull(result); + } else { + assertEquals(expected.toString(), result.toString()); + } + } + + @Test + public void testTimestampDefaultTimezone() throws HiveException { + ObjectInspector valueLongOI = PrimitiveObjectInspectorFactory.writableLongObjectInspector; Review comment: IntObjectInspector is removed from the code. so no need to add anything for that in the test. -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 634641) Time Spent: 2h (was: 1h 50m) > from_unixtime() does not consider leap seconds > ----------------------------------------------- > > Key: HIVE-25403 > URL: https://issues.apache.org/jira/browse/HIVE-25403 > Project: Hive > Issue Type: Sub-task > Components: Hive > Reporter: Sruthi Mooriyathvariam > Assignee: Sruthi Mooriyathvariam > Priority: Major > Labels: pull-request-available > Fix For: 3.1.2 > > Attachments: image-2021-07-29-14-42-49-806.png > > Time Spent: 2h > Remaining Estimate: 0h > > The Unix_timestamp() considers "leap second" while the from_unixtime is not; > which results in to wrong result as below: > !image-2021-07-29-14-42-49-806.png! -- This message was sent by Atlassian Jira (v8.3.4#803005)