vdiravka commented on a change in pull request #1494: DRILL-6768: Improve 
to_date, to_time and to_timestamp and correspondi…
URL: https://github.com/apache/drill/pull/1494#discussion_r226602039
 
 

 ##########
 File path: exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
 ##########
 @@ -65,28 +65,28 @@
   public void setup() { }
 
   public void eval() {
-    <#if type.major == "EmptyStringVarCharDateComplex">
+    <#if type.major == "NullableVarCharDate">
     if(<#if type.from == "NullableVarChar" || type.from == "NullableVar16Char" 
|| type.from == "NullableVarBinary">in.isSet == 0 || </#if>in.end == in.start) {
       out.isSet = 0;
       return;
     }
     out.isSet = 1;
     </#if>
 
-    <#if type.to != "Date" && type.to != "NullableDate">
+    <#if !type.to?contains("Date")>
     byte[] buf = new byte[in.end - in.start];
     in.buffer.getBytes(in.start, buf, 0, in.end - in.start);
     String input = new String(buf, com.google.common.base.Charsets.UTF_8);
     </#if>
-      
-    <#if type.to == "Date" || type.to == "NullableDate">
+
+    <#if type.to?contains("Date")>
     out.value = 
org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.getDate(in.buffer, 
in.start, in.end);
 
-    <#elseif type.to == "TimeStamp" || type.to == "NullableTimeStamp">
+    <#elseif type.to?contains("TimeStamp")>
 
 Review comment:
   Is this just for simplifying? If yes, in future it can work not as expected 
for newly added data types formats, for instance `TimestampTZ`.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to