amansinha100 commented on code in PR #4675:
URL: https://github.com/apache/hive/pull/4675#discussion_r1322481197


##########
ql/src/test/resources/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFDateFormatEvaluate.csv:
##########
@@ -0,0 +1,39 @@
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Etc/GMT;DATETIME;1970-01-01 00:00:00
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Etc/GMT;SIMPLE;1970-01-01 00:00:00
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Atlantic/Azores;DATETIME;1970-01-01 
00:00:00
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Atlantic/Azores;SIMPLE;1970-01-01 
00:00:00
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss z;Etc/GMT;DATETIME;1970-01-01 00:00:00 
GMT
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss z;Etc/GMT;SIMPLE;1970-01-01 00:00:00 
GMT
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss z;Atlantic/Azores;DATETIME;1970-01-01 
00:00:00 AZOT
+1970-01-01 00:00:00;yyyy-MM-dd HH:mm:ss z;Atlantic/Azores;SIMPLE;1970-01-01 
00:00:00 AZOT
+1970-01-01 00:00:00 GMT-01:00;yyyy-MM-dd HH:mm:ss 
z;Etc/GMT;DATETIME;1970-01-01 00:00:00 GMT
+1970-01-01 00:00:00 GMT-01:00;yyyy-MM-dd HH:mm:ss z;Etc/GMT;SIMPLE;1970-01-01 
00:00:00 GMT
+1800-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Etc/GMT;DATETIME;1800-01-01 00:00:00
+1800-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Etc/GMT;SIMPLE;1800-01-01 00:00:00
+1800-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Asia/Kolkata;DATETIME;1800-01-01 
00:00:00
+1800-01-01 00:00:00;yyyy-MM-dd HH:mm:ss;Asia/Kolkata;SIMPLE;1799-12-31 23:36:32
+Jul 9 2023;MMM dd yyyy;Etc/GMT;DATETIME;null
+Jul 9 2023;MMM dd yyyy;Etc/GMT;SIMPLE;null

Review Comment:
   I assume the null at the end implies this failed to parse even with the 
SIMPLE format.  Is it because of the single digit date '9' instead of '09' ?  I 
thought that the SIMPLE formatter is less strict about this. 



##########
ql/src/test/org/apache/hadoop/hive/ql/udf/generic/TestGenericUDFDateFormatEvaluate.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.conf.HiveConf;
+import org.apache.hadoop.hive.ql.metadata.HiveException;
+import org.apache.hadoop.hive.ql.session.SessionState;
+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.objectinspector.ObjectInspector;
+import 
org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
+import org.apache.hadoop.hive.serde2.typeinfo.TypeInfoFactory;
+import org.apache.hadoop.io.Text;
+
+import com.opencsv.CSVParser;
+import com.opencsv.CSVParserBuilder;
+import com.opencsv.CSVReader;
+import com.opencsv.CSVReaderBuilder;
+import com.opencsv.exceptions.CsvException;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.Objects;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests for {@link GenericUDFDateFormat#evaluate(DeferredObject[])} with 
string value inputs.
+ */
+@RunWith(Parameterized.class)
+public class TestGenericUDFDateFormatEvaluate {
+  private final GenericUDFDateFormat udf = new GenericUDFDateFormat();
+  private final String value;
+  private final String pattern;
+  private final String zone;
+  private final String formatter;
+  private final Text expectedResult;
+
+  public TestGenericUDFDateFormatEvaluate(String value, String pattern, String 
zone, String formatter,
+      String expectedResult) {
+    this.value = value;
+    this.pattern = pattern;
+    this.zone = zone;
+    this.formatter = formatter;
+    this.expectedResult = expectedResult.equals("null") ? null : new 
Text(expectedResult);
+  }
+
+  @Parameterized.Parameters(name = "('{0}','{1}'), zone={2}, formatter={3}")
+  public static Collection<String[]> readInputs() throws IOException, 
CsvException {
+    CSVParser parser = new 
CSVParserBuilder().withSeparator(';').withIgnoreQuotations(true).build();
+    try (InputStream in = 
TestGenericUDFDateFormatEvaluate.class.getResourceAsStream(

Review Comment:
   A brief comment about the structure of the CSV file would be useful for 
future extensibility. Which ones are the input fields and which are output 
etc.. 



-- 
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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org
For additional commands, e-mail: gitbox-h...@hive.apache.org

Reply via email to