Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cgivre committed Nov 3, 2023
1 parent d209678 commit 7d00472
Showing 1 changed file with 2 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,6 @@
<#include "/@includes/license.ftl"/>
<<<<<<< HEAD
package org.apache.drill.exec.expr.fn.impl;
import org.apache.drill.exec.expr.DrillSimpleFunc;
import org.apache.drill.exec.expr.annotations.FunctionTemplate;
import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
import org.apache.drill.exec.expr.annotations.Output;
import org.apache.drill.exec.expr.annotations.Workspace;
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.holders.*;
import org.apache.drill.exec.record.RecordBatch;
=======
package org.apache.drill.exec.expr.fn.impl;
import org.apache.drill.exec.expr.DrillSimpleFunc;
Expand All @@ -44,7 +32,6 @@
import org.apache.drill.exec.expr.annotations.Param;
import org.apache.drill.exec.expr.holders.*;
import org.apache.drill.exec.record.RecordBatch;
>>>>>>> 5c8cb1d28 (Merge commits from @vvysotskyi)
/*
* This class is generated using freemarker and the ${.template_name} template.
Expand All @@ -55,59 +42,6 @@ public class ${className} {
<#list dateIntervalFunc.dates as toUnit>
<<<<<<< HEAD
@FunctionTemplate(name = "timestampadd${unit}",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
public static class TimestampAdd${unit}to${toUnit} implements DrillSimpleFunc {
@Param BigIntHolder count;
@Param ${toUnit}Holder right;
<#if toUnit == "Time">
@Output TimeHolder out;
<#else>
@Output TimeStampHolder out;
</#if>
public void setup() {
}
public void eval() {
long countValue = count.value;
<#if unit == "Nanosecond">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.NANOS;
<#elseif unit == "Microsecond">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.MICROS;
<#elseif unit == "Millisecond">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.MILLIS;
<#elseif unit == "Second">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.SECONDS;
<#elseif unit == "Minute">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.MINUTES;
<#elseif unit == "Hour">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.HOURS;
<#elseif unit == "Day">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.DAYS;
<#elseif unit == "Week">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.WEEKS;
<#elseif unit == "Month">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.MONTHS;
<#elseif unit == "Year">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.YEARS;
<#elseif unit == "Quarter">
java.time.temporal.TemporalUnit unit = java.time.temporal.ChronoUnit.MONTHS;
// Quarter has 3 month
countValue *= 3;
</#if>
long result = java.time.LocalDateTime.ofInstant(java.time.Instant.ofEpochMilli(right.value), java.time.ZoneOffset.UTC).plus(countValue, unit).toInstant(java.time.ZoneOffset.UTC).toEpochMilli();
<#if toUnit == "Time">
out.value = (int) (result % org.apache.drill.exec.vector.DateUtilities.daysToStandardMillis);
<#else>
out.value = result;
</#if>
}
}
=======
@FunctionTemplate(name = "timestampadd${unit}",
scope = FunctionTemplate.FunctionScope.SIMPLE,
nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
Expand All @@ -120,8 +54,10 @@ public static class TimestampAdd${unit}to${toUnit} implements DrillSimpleFunc {
<#else>
@Output TimeStampHolder out;
</#if>
public void setup() {
}
public void eval() {
long countValue = count.value;
<#if unit == "Nanosecond">
Expand Down Expand Up @@ -157,7 +93,6 @@ public void eval() {
</#if>
}
}
>>>>>>> 5c8cb1d28 (Merge commits from @vvysotskyi)

</#list>
</#list>
Expand Down

0 comments on commit 7d00472

Please sign in to comment.