[ 
https://issues.apache.org/jira/browse/DRILL-6544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16604595#comment-16604595
 ] 

ASF GitHub Bot commented on DRILL-6544:
---------------------------------------

agozhiy commented on a change in pull request #1449: DRILL-6544: Timestamp 
value in Drill UI showed inconsistently with th…
URL: https://github.com/apache/drill/pull/1449#discussion_r215328351
 
 

 ##########
 File path: 
exec/java-exec/src/test/java/org/apache/drill/exec/util/TestVectorUtil.java
 ##########
 @@ -0,0 +1,154 @@
+/*
+ * 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.drill.exec.util;
+
+import org.apache.drill.common.types.TypeProtos;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.server.options.OptionManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+
+import static junit.framework.TestCase.assertTrue;
+import static org.mockito.Mockito.when;
+
+public class TestVectorUtil {
+
+  @Mock
+  OptionManager options;
+
+  @Before
+  public void setup(){
+    MockitoAnnotations.initMocks(this);
+  }
+
+  @Test
+  public void testFormatValueVectorElementTimestampEmptyPattern(){
+    
when(options.getString(ExecConstants.WEB_TIMESTAMP_DISPLAY_FORMAT)).thenReturn("");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalDateTime.of(2012, 11, 5, 13, 0, 30, 120000000),
+        TypeProtos.MinorType.TIMESTAMP,
+        options);
+    assertTrue(formattedValue.equals("2012-11-05T13:00:30.120"));
+  }
+
+  @Test
+  public void testFormatValueVectorElementTimestampValidPattern(){
+    
when(options.getString(ExecConstants.WEB_TIMESTAMP_DISPLAY_FORMAT)).thenReturn("yyyy-MM-dd
 HH:mm:ss.SS");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalDateTime.of(2012, 11, 5, 13, 0, 30, 120000000),
+        TypeProtos.MinorType.TIMESTAMP,
+        options);
+    assertTrue(formattedValue.equals("2012-11-05 13:00:30.12"));
+  }
+
+  @Test
+  public void testFormatValueVectorElementTimestampInvalidPattern(){
+    
when(options.getString(ExecConstants.WEB_TIMESTAMP_DISPLAY_FORMAT)).thenReturn("Invalid
 Pattern");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalDateTime.of(2012, 11, 5, 13, 0, 30, 120000000),
+        TypeProtos.MinorType.TIMESTAMP,
+        options);
+    assertTrue(formattedValue == null);
+  }
+
+  @Test
+  public void testFormatValueVectorElementDateEmptyPattern(){
+    
when(options.getString(ExecConstants.WEB_DATE_DISPLAY_FORMAT)).thenReturn("");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalDate.of(2012, 11, 5),
+        TypeProtos.MinorType.DATE,
+        options);
+    assertTrue(formattedValue.equals("2012-11-05"));
+  }
+
+  @Test
+  public void testFormatValueVectorElementDateValidPattern(){
+    
when(options.getString(ExecConstants.WEB_DATE_DISPLAY_FORMAT)).thenReturn("EEE, 
MMM d, yyyy");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalDate.of(2012, 11, 5),
+        TypeProtos.MinorType.DATE,
+        options);
+    assertTrue(formattedValue.equals("Mon, Nov 5, 2012"));
+  }
+
+  @Test
+  public void testFormatValueVectorElementDateInvalidPattern(){
+    
when(options.getString(ExecConstants.WEB_DATE_DISPLAY_FORMAT)).thenReturn("Invalid
 Pattern");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalDate.of(2012, 11, 5),
+        TypeProtos.MinorType.DATE,
+        options);
+    assertTrue(formattedValue == null);
+  }
+
+  @Test
+  public void testFormatValueVectorElementDateUnsupportedPattern(){
+    
when(options.getString(ExecConstants.WEB_DATE_DISPLAY_FORMAT)).thenReturn("yyyy-MM-dd
 HH:mm:ss.SS");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalDate.of(2012, 11, 5),
+        TypeProtos.MinorType.DATE,
+        options);
+    assertTrue(formattedValue == null);
+  }
+
+  @Test
+  public void testFormatValueVectorElementTimeEmptyPattern(){
+    
when(options.getString(ExecConstants.WEB_TIME_DISPLAY_FORMAT)).thenReturn("");
+    String formattedValue = VectorUtil.formatValueVectorElement(
+        LocalTime.of(13, 0, 30, 120000000),
+        TypeProtos.MinorType.TIME,
+        options);
+    assertTrue(formattedValue.equals("13:00:30.120"));
 
 Review comment:
   Fixed

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


> Timestamp value in Drill UI showed inconsistently with the same value 
> retrieved from sqline
> -------------------------------------------------------------------------------------------
>
>                 Key: DRILL-6544
>                 URL: https://issues.apache.org/jira/browse/DRILL-6544
>             Project: Apache Drill
>          Issue Type: Bug
>    Affects Versions: 1.14.0
>            Reporter: Anton Gozhiy
>            Assignee: Anton Gozhiy
>            Priority: Minor
>
> *Query:*
> {code:sql}
> select timestamp '2008-2-23 12:23:34' from (values(1));
> {code}
> *Expected result (from sqline):*
> 2008-02-23 12:23:34.0
> *Actual result (from Drill UI):*
> 2008-02-23T12:23:34



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to